Dynamically call a getter method with reflection?

I have a page that prints out some report info, but only for the group of columns requested. What I need to do, based upon a String containing a column name that is passed in as input, is call that column's getter method dynamically...
Does anyone have any good examples of doing this?
Thanks,
Mike

Not sure if dynamic replacement of the property name works, but you could try
<jsp:getProperty name="myBean" property="<%=request.getParameter("col1")%>"/>
Where myBean is the name of your object and col1 is the name of your property, not the function name. So, if you have a function named getType(), then your variable is named type. So you would pass type as the property, like
<jsp:getProperty name="myBean" property="type"/>
This dynamically calls the getType() method on your object myBean.

Similar Messages

  • Non-varargs call of varargs method with inexact argument type for last para

    i have no idea what the error:
    non-varargs call of varargs method with inexact argument type for last parameter
    means.
    return (Component)sceneClass.getConstructor(
    new Class[]{int.class, int.class}).newInstance(
         new Integer[]{new Integer((int)sceneDimension.getWidth()),
                new Integer((int)sceneDimension.getHeight())});
    this is the problem area but i'm not sure how to get around it..
    any help would be appreciated

    I am a Java learner and I got the same warning. My code runs like this:
    import java.lang.reflect.*;
    class Reflec
         public static void main(String[] args)
              if(args.length!=1)
                   return;
              try
                   Class c=Class.forName(args[0]);
                   Constructor[] cons=c.getDeclaredConstructors();
                   Class[] params=cons[0].getParameterTypes();
                   Object[] paramValues=new Object[params.length];
                   for(int i=0; i<params.length; i++)
                        if(params.isPrimitive())
                             paramValues[i]=new Integer(i+3);
                   Object o=cons[0].newInstance(paramValues);
                   Method[] ms=c.getDeclaredMethods();
                   ms[0].invoke(o, null);
              catch(Exception e)
                   e.printStackTrace();
    class Point
         static
              System.out.println("Point class file loaded and an object Point generated£¡");     
         int x, y;
         void output()
              System.out.println("x="+x+"\ny="+y);
         Point(int x, int y)
              this.x=x;
              this.y=y;
    When I compiled the file I got the following:
    Reflec.java:26: warning: non-varargs call of varargs method with inexact argument type for last parameter;
    cast to java.lang.Object for a varargs call
    cast to java.lang.Object[] for a non-varargs call and to suppress this warning
    ms[0].invoke(o, null);
    ^
    1 warning
    Since the problem was with this line "ms[0].invoke(o, null);" and the specific point falls on the last argument as the warning mentioned that " ... method with inexact argument type for last parameter", I simply deleted the argument "null" and the line becomes "ms[0].invoke(o);" and it works, no warning anymore!
    DJ Guo from Xanadu
    Edited by: Forget_Me_Not on Jan 8, 2009 10:39 AM

  • Best practice for calling an AM method with parameters

    Which will be the best way to call an AM method with parameters from a backing bean.
    I usually use the BindingContainer to get the operation binding and then call execute function. But when the method have parameters, how to do it?
    Thanks

    Hi,
    same:
    operationBinding.getParamMap().put("argument1Name", argument1Value);
    operationBinding.getParamMap().put("argument2Name", argument2Value);
    operationBinding.execute();
    Frank

  • How to call a AM method with parameters from Managed Bean?

    Hi Everyone,
    I have a situation where I need to call AM method (setDefaultSubInv) from Managed bean, under Value change Listner method. Here is what I am doing, I have added AM method on to the page bindings, then in bean calling this
    Class[] paramTypes = { };
    Object[] params = { } ;
    invokeEL("#{bindings.setDefaultSubInv.execute}", paramTypes, params);
    This works and able to call this method if there are no parameters. Say I have to pass a parameter to AM method setDefaultSubInv(String a), i tried calling this from the bean but throws an error
    String aVal = "test";
    Class[] paramTypes = {String.class };
    Object[] params = {aVal } ;
    invokeEL("#{bindings.setDefaultSubInv.execute}", paramTypes, params);
    I am not sure this is the right way to call the method with parameters. Can anyone tell how to call a AM method with parameters from Manage bean
    Thanks,
    San.

    Simply do the following
    1- Make your Method in Client Interface.
    2- Add it to Page Def.
    3- Customize your Script Like the below one to Achieve your goal.
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("GetUserRoles");
    operationBinding.getParamsMap().put("username", "oracle");
    operationBinding.getParamsMap().put("role", "F1211");
    operationBinding.getParamsMap().put("Connection", "JDBC");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    return null;
    i hope it help you
    thanks

  • HT201195 Who can I call about getting help with redeeming my iTunes card?

    Title is pretty self explanatory: Who can I call about getting help with redeeming my iTunes card?

    There isn't a phone number for iTunes Support, you can contact them via this page (you will probably need to give them images of the front and back of the card, and possibly its receipt) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then iTunes Cards And Codes

  • How to call a C method with Java

    Hi all,
    is it possible calling a C method with Java?? And how to...?
    thx for helping
    Cobol1

    is it possible calling a C method with Java?? And how to...?Not in general no.
    You can use JNI which will call another C function (which you write) and which then calls your C method.
    If the method is of a specific type (like OLE, Corba) then there are packages available which can allow you to access it. They still use JNI underneath, but hide that functionality from you.

  • Dynamic call of a vi with a reference stored in a global variable

    Hello,
    I am trying to program a VI which calls DAQmx functions in some cases, in other cases DAQmx may not even be installed. To prevent a broken arrow on machines where DAQmx is not installed, I want to use a sub-VI containing the DAQmx function calls which is called dynamically by a main VI. For speed I want to prevent continuous opening and closing the VI reference, so I want to store the reference to the sub VI in a global variable. In this variable I also want to store the Analog Input Task. I want to use an initialization VI to write the VI reference of the sub VI and to configure and start the Analog Input Task and write the Task ID to that Global, too. In that way I was hoping to be able to improve the performance of the dynamic calls and the Task calls. BUT - when I write the refererence and task to the Global and read it out from another VI, the reference is not valid anymore and the Analog Input task is also not valid, even if both the initialization VI and the Global are still open (but not running). Does somebody have an idea how to solve that? It is a bit difficult to describe, so here is what I want to do in a shorter description :
    - run a initialization VI which
      defines a reference to a sub VI which will be called dynamically later on
      and a AI task ID definining a DAQmx physical channel configuration to use for subsequent read cycles
      and writes both (VI reference and AI task) to a global variable
    - run another VI which
      reads the VI reference of the VI to call dynamically from that global
      runs the corresponding VI dynamically
      the dynamically called VI performs an AI task corresponding to the DAQmx task ID read from that global (it reads an analog value for instance from the  
      physical channel configured by that AI task) 
    Why all that? To prevent creating and destroying the VI reference for each call of the sub VI for speed. And to use the configured DAQmx channel for subsequent read tasks only if the subVI is called dynamically - if it is not, then the application will not see the DAQmx calls and therefore no broken arrow will occur if no DAQmx is installed on the machine.
    Can somebody help me with this? Why can't I store and read out the reference to the sub VI to/from a global, and why is the AI task not valid when read out from the dynamically called sub VI? I am somewhat lost with all that...
    Thanks in advance,
    Gabs

    Uh - I am almost getting crazy with that
    Kevin, that solution is the right one for programming an application. In that case everything will work fine. But during testing, it is more convenient to call all VIs from their front panels one after another. That's how I'm doing it for everything that needs to be exchanged between such VIs: store them either in a global or in a functional global variable. In that way the user can "play around" with the VIs without wiring them together in a main VI. Therefore, after some thinking I liked Davids idea with that daemon VI (I solved that by adding a boolean in the initialization VI to choose if that daemon is necessary - during testing phase - or not - when using the VIs in a main application). BUT:
    David: It does not work!!! I have exactly done what you proposed and this daemon VI is really running, having a True/False frame with a constant of False wired to the selector and holding both the functional global and the dynamically to call VI in the True frame. In that way, after initialization is finished, both VIs are still running but idle. Anyway, when I read back the value of the reference or the DAQmx task, it is invalid again!
    That really costs just too much time. Does anybody have any idea what to do now? David, I was hoping that your suggestion would solve the problem, because it would be logical that it would - why then is LabVIEW destroying the reference and task anyway even if that daemon VI containing the functional global is still running???
    Regards,
    Gabs

  • Rhino calling overloaded Java methods with Array parameters

    Has anyone had any problems writing JavaScript code that calls overloaded Java methods?
    I have two Java defined methods that differ in the arguments, one takes a string the other takes an array of strings. The problem is calling Java methods within the JavaScript always calls the method with the String argument...
    /* Java Code Here */
    public void function(String s) { /* Function A */ }
    public void function(String[] sa) { /* Function B */ }
    /* JavaScript  Code Here */
    param = java.lang.reflect.Array.newInstance(java.lang.String, 2);
    param[0] = "test";
    param[1] = "test2";
    stringParam = "test3";
    /* Both function calls below end up calling the Function A from above */
    function(param);
    function(stringParam);PS...in case you're not familiar with Rhino,
    It is a mozilla package that embeds a JavaScript interpreter within a Java application...
    http://www.mozilla.org/rhino/

    haha...I can't even find my other thread :(
    Sorry about the double post...I'll go look for my other thread now

  • Dynamic Change event getting error with cascading LOV's

    Hi all,
    In my application (v4.0.0), I have two sets of cascading drop-down select lists, these each make up a date (year, month, day) plus a time value (not cascading).
    I also have a dynamic action that gets the hours difference between the two dates set above. This fires on the change event.
    When I change, say the month drop-down, the day list is refreshed. But before it is refreshed, it looks to be emptied and the change event fires. I then get an error from the dynamic action because the day value passed to the query is empty (confirmed when looking at POST data).
    Can anyone think of a workaround idea for this? e.g. a way to set the dynamic action to conditional?
    Thanks!

    Hi Peter
    Thanks for the tip, I have tried this and it has helped, although not solved the problem. I was originally getting two errors appear ("AJAX call returned server error ORA-01843: not a valid month for Set Value.") and this has removed one of them...
    When looking in Firebug, it seems to me that although the dynamic actions (cascading update + set value) are running one before the other, the values aren't updated in order. e.g. the cascading update is not applied before the set value action is run.
    Could this be a bug with dynamic actions?

  • Invoking method with reflection - with String[] params

    Hi there,
    I have a method that I need to call with reflection. This method has one parameter
    public void setArgs(String args[])
    I'm trying to invoke it by reflection. I tryied this but didn't work:
    Class[] parameterArgs = {String[].class};
    Method mCallArgs = objClasseChiamata.getClass().getMethod("setArgs",parameterArgs);
    Object[] nomeArgs = new Object[]{"Luca","Alessio"};
    //I try too:
    //String[] nomeArgs = new String[]{"Luca","Alessio"};
    mCallArgs.invoke(objClasseChiamata ,nomeArgs);     
    It compile ok,
    but in Runtime I find this error:
    java.lang.IllegalArgumentException
    java.lang.Throwable()
    java.lang.Exception()
    java.lang.RuntimeException()
    java.lang.IllegalArgumentException()
    java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object [])
    void reflection.TestReflection.main(java.lang.String [])
    Thank you,
    Alessio

    The thing that goes in the Object[] is the paramaters. The parameter is one String[], not two Strings:
    Object[] nomeArgs = { new String[] {"Luca", "Alessio"} };
    mCallArgs.invoke(objClasseChiamata ,nomeArgs);
    // or
    mCallArgs.invoke(objClasseChiamata, new Object[] { new String[] {"Luca", "Alessio"} });Note that there's no reason to use "new Object" when you're initializing a named array reference (just like you initialized the Class[] above).

  • Hello. I am a blind user. Is there a number to call to get help with an unauthorized purchase?

    I am having trouble using the report a problem thru ITunes. Selected report a problem but just not sure it has been reported. Did this last Friday and have heard nothing from Apple.

    There is no official phone support for the iTunes Store, but you can try calling Apple technical support, explain about your vision problem, and see if they can find out anything for you. If you'll post what country you're in, we can give you the appropriate phone number if you don't have it already.
    You can also try the Express Lane contact form for the iTunes Store, if you can fill it out:
    http://www.apple.com/support/itunes/contact/
    I have often found that to be a more reliable way of getting through to the iTunes Store than is the "report a problem" feature within iTunes. There are several steps to get through with Express Lane, though, so it may be difficult with a screen reader.
    Regards.

  • Dynamically creating setter/getter methods

    Hi All,
    I want to created a Java Bean with setter/getter methods. I know how to do this for fixed number of items like setProduct1,setProduct2 etc . BUT in my case, I can have variabe number of Products and hence want want to create setProduct1...setProductn methods. Any help to do this will be greatly appreciated. I can know in advance how many of setter methods I have to create but they may vary with each request.
    Thanks
    Vinod

    Instead, maybe try making a bean with methods such as this:
    public void addProduct( Product product ) {
        this.products.add( product );
    public List getProducts ( ) {
        return ( this.products );
    }

  • GET Method with long query string

    Hi there,
    Not sure if this has already been answered. Sorry if it has!
    I have a Biztalk application which does a pass-through for all http requests. It is using WCF-WebHttp transport type with URL mapping of /*.
    It works fine except for GET method that has query string longer than 256 characters. It chokes with following exception:
    The adapter "WCF-WebHttp" raised an error message. Details "System.ArgumentOutOfRangeException: The value of promoted property cannot exceed 256 characters. Property "To" Namespace "http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties".
    My question is is there a workaround for this e.g. extend the string length limit? 

    Hi Karsten,
    Try giving the one part of URL in address box and other pass the arguments inside HTTP Method and URL Mapping dialog.
    Eg:
    Address (URI) : https://btstecheddemostorage.blob.core.windows.net
    <BtsHttpUrlMapping>
    <Operation Name="ListFiles"
    Method="GET" Url="/{mycontainer}?restype=container&amp;comp=list"
    /> </BtsHttpUrlMapping>
    Thank YOu,
    Tamil

  • Dynamic Call Function/Class Method

    Hi,
    I have a requirement for which I need your help.
    I want to Call a Method dynamically inside a program. how to do it?
    My another quary is that how to call more than one class method dynamicaly in the program one at a time, based on certain conditions.
    All the requirements mentioned above feels awakward to me, but are they feasible. Eagerly waiting for a reply.
    Regards,
    Pulokesh
    Moderator message - Cross post locked
    Edited by: Rob Burbank on Oct 26, 2009 9:48 AM

    Hello,
    you can call a Method like this where the name of the method is concatenated.
    CONCATENATE 'SC_' me->gf_scenario '_SAVE' INTO lf_method.
      CALL METHOD me->(lf_method).
    Than I can imagine to loop over a tabele with all the Method Call to be executes un there:
    Loop at gt_meth_calls into ls_meth_call.
       ls_meth_call-object_instance->(ls_meth_call-meth_name).
    endloop.
    The table should be structured such that the first component contains a reference to the instance and the second component will be the Method name to run.

  • Calling Backing Bean Method with h:outputLink

    Is there a way to call a backing bean using h:outputLink isntead of h:commandLink ?

    No, you can't. You however can just let it point to a JSF page and make use of the constructor of the involved request scoped managed bean.

Maybe you are looking for

  • How can I listen to a gifted iTunes song without adding my credit card?

    I am having an absolute nightmare of a time with Apple. A friend gifted me with a song on iTunes. I do not have iTunes and am not a Mac user. I have found that the computers always add unnecessary steps and procedures and make even simple things far

  • Can't get email for past three days on iPad.

    I have an iPad2 and for past three days when I go to Mail app the "checking..." message at the bottom just goes on and on and nothing ever comes in. My Mail on iPhone and my MacBookPro all come in fine.   I have tried changing my Apple I'd password,

  • Toshiba 320GB external HDD suddenly thinks it is my 160GB disc!

    PC: Toshiba Satellite A305D-S6848 Accessories: Toshiba 320GB external USB hard drive; MODEL: HDDR320E03X Toshiba 160GB external USB hard drive; MODEL: HDDR160E03X The other day I started my laptop with both of these drives already connnected. Suddenl

  • Why won't my HTML page display my applet?

    I can't figure this out. It works fine through Sun's appletviewer. Here is my HTML code: <applet code="backGroundSwing.class" height=200 width=500></applet> Here is my applet code: import javax.swing.*; import java.awt.*; import java.awt.event.*; imp

  • Update ical and address book on iMac does not update iPhone or ipad

    I have updated my ical and address book on my imac, but it is not updating my iphone or ipad, I have activated icloud on all machines, can anyone help please. Have looked at the forum, but cannot find my issue specifically. Regards