How to Call a method that takes in a parameter from JSF Fragment

Hi,
When we want to call the getter method of a backingbean field in a JSF Fragment we merely do a #{bean.fieldName} which will ensure that a getFieldName () will be invoked on the bean....and the value is returned.
Now Suppose i have a method say
String method1(String) and i wnt use this method in the JSFF. How woudl i do that because this method is taking a parameter so i cannot do a plain #{bean.fieldName}
Any ideas
Thanks
Karthik

Hello Karthik,
You can achieve it using an EL hack. If the managed bean implements map, then an expression like #{bean[myParameter]} will call bean.get(myParameter) and you can then redispatch to your other method.
Regards,
~ Simon

Similar Messages

  • How to write a method that takes two arguments of same type

    Hi,
    I seldom do anything "advanced" in generics, but I've done my reading, and thought that I had an understanding of the basics, but I'm stuck on this. How do I write a method that takes two arguments that must be of exact same type.
    I've tried something like:
    public class GenericsTest1 {
        public static <T> void compare(T first, T second) {
    }But the compare method can in this case be called with e.g.
    String arg1 = null;
    Long arg2 = null;
    compare(arg1, arg2);I can restrict the call to something like GenericsTest1.<Long>compare(arg1, arg2), but I don't want to do it in the location that calls the method, and the method can still be invoked with subclasses of the specified type. E.g. this is valid (but I don't want it to be valid):
    Number arg1 = null;
    Long arg2 = null;
    GenericsTest1.<Number>compare(arg1, arg2);So I then changed the method into something like this:
    public class GenericsTest2 {
        public static <T, E extends T> void compare(T first, E second) {
    }It feels like I'm half way there now. Compare can't be called with e.g:
    Long arg1 = null;
    Number arg2 = null;
    compare(arg1, arg2);But this is still valid:
    Number arg1 = null;
    Long arg2 = null;
    compare(arg1, arg2);Hmm... So what to do? I only want the method to be callable when arg1 and arg2 is of exact same type. Everything else should give a compilation error.
    Kaj
    Ps. No, I don't have a need for this, I'm just curious.

    dannyyates wrote:
    I haven't gone through everything you've written, but I would expect that in the first instance, it's inferred <T> to be Object. This is a good reason to parameterise the class rather than the method wherever that makes sense.Thanks for you reply, but as I said this isn't related to anything that I'm going to use. I just want to know if it ca ben done with a static method and generics.
    Kaj

  • Calling a method in the Custom ADF component from JSF page

    HI.
    I have created some custom compoents by extending the core ADF Components. Like i have a ComboBoxDefault component with it's ComboBoxDefaultTag.java and Controls.tld file.
    Now my requirement is i want to bind my label to this component from the JSF page. like
    <fwcontrols:label binding="#{listComponents.comboBoxDefaultLabel}" id="label1"/>
    <fwcontrols:comboBoxDefault binding="#{listComponents.cmbLocales}"
    value="en_GB" id="comboBoxDefault" autoSubmit="true" label="label1">
    <f:selectItems value="#{listComponents.locales}"/>
    </fwcontrols:comboBoxDefault>
    In my JSF page the label will have an id, and that id will be specified in the label tag of the component.
    In Tag.java file i have overrided the setProperty(FacesBean facesBean). In this method i have bind all my properties. In core JSF the setProperty method is provided with the UIComponent parameter, so i can call my method in component also. Which is not in case of ADF Faces.
    My main point is how i can call my method setLabel() which is in ComboBoxDefault.java so that i can set the label.
    Thanks in Advance.

    Thanks for all your replies. I want this kind of a functionality because Im trying to invove a DC (Child DC) from a Parent DC such that the Child DC's view is displayed onto the view container of the Parent DC. I have embedded using 'interface view of a component instance' in the Parent Window and am able to create the component and set usage though the onPlugDefault of the Child View.
    But I observe that when i make a call from the parent, the flow is like this:
    1. The wdDoInit of the Child Component Controller gets triggered first.
    2. Then the wdDoInit of the Child's <b>VIEW</b> gets triggered
    3. and <b>THEN</b> the onPlugDefault of the Child Component Interface View
    What I had actually wanted was to Fire onPlugDefault where Im calling a method LoadData(), after which the Child DC's view must be triggered so it can display the fetched data.
    What is actually happening is the view gets displayed, but no data is displayed in the view.
    Right now I have just given a work around where Im triggering <b>LoadData()</b> of the <b>COmponent COntroller</b> from the <b>wdDoInit</b> of the <b>VIEW</b>.
    Is there a better way to do this? I find it strange that I have to load the Data from the view.
    Thanks
    Jack

  • How to call a method in a flash file (swf) from another fl;ash file (swf) and vica versa ?

    Hi, I have a Flash file (Flash1.fla). I have a  public method, method1() in a public class of the file. I have another Flash file (Flash2.fla). I have a public method, method2()  in the public class of this file. I want to call the method1() from Flash2.swf and the method2() from Flash1.swf. Please help!!

    swf-to-swf communication
    http://kb2.adobe.com/community/publishing/918/cpsid_91887.html

  • How to call a method in the servlet from an applet

    I want to get the data for the applet from the servlet.
    How to call a method that exits in the servlet from the applet? I want to use http protocol to do this.
    Any suggestions? Please help.
    thanks

    Now that Web Services is around, I'd look at possibly implement a Web Service call in your applet, which can then be given back any object(s) on return. Set up your server side to handle Web Service calls. In this way, you can break the applet out into an application should you want to (with very little work) and it will still function the same

  • [naming issue] how to call a method...

    Now, this may sound silly, but believe me, for a non-english guy sometimes those naming issues are really serious (especially when you know someone else is to see your code). So what I'm doing is a network simulation software (my b.sc. project). How would you call a method that takes traffic into a queue/network node (let's call it METHOD1 for now) and a method that pushes that traffic out (METHOD2). It's more or less like this:
    class TransmissionLine{
       private Node node1;
       private Node node2;
       public void performAction(){
          node1.METHOD1(node2.METHOD2());
          node2.METHOD1(node1.METHOD2());
    }Right now they are called TrafficUnit push(), and void pull(TrafficUnit tu). Seems good for me since the first pushes its traffic out, and the second pulls it in, but I dont know - it doesn't sound pro ;) Please let me now what you think and what would you call them. Thanks!
    Best Regards,
    M.

    I think when you're talking about some functionality that links two classes together, one of which needs to generate data and the other which needs to receive data, send and receive is probably still a good choice. Even if you're not talking about a network, you're talking about two independent parts of a system. Think of them as little machines that build up your program, and that might give you a good idea of how you should name them.
    On the other hand, if you're just looking for readable code, pick something that makes sense to you if you were describing the method to someone else, and then make sure you write clear comments. Even if you pick a name that's not perfect, the comments will make up for it. Something like:
      * Gets the traffic coming in so that it can be processed.
      * @param node The sending node
      * @return The traffic data from the sending node
    public TrafficData pull(TrafficUnit node)
      * Sends the traffic data out to the target after processing.
    public void push()
    ..This will always be better than...
    public TrafficData receive(TrafficUnit node)
    public void send()
    ...

  • How to call Java methods from a Windows application?

    Hello all,
    At our company, we need to integrate our product which is a Java Swing application with a Windows application. Specifically, we are trying to call Java methods that reside in our application from the Lotus Notes email client application, which is a native Windows application. Such that when a user clicks a button in the Lotus Notes email client, it will trigger an event in our Swing application. Is this possible using JNI? Do you know of any resources or references relating to this kind of a project?
    Thanks,
    Mete Kural

    If there is some dll interface that lets Lotus Notes load up and use a DLL, then yes, this should be possible.

  • EL - How do you call a method that requires a parameter

    How do you call a method that requires a parameter
    In scriplet code here is what I am trying to do
    <%= car.getDefaultColor(car.getCarType()) %>
    How do I do this in EL
    Here is my guess (it generates the Exception described below)
    ${car.defaultColor(car.carType)}
    Here is the Exception I am getting:
    javax.servlet.ServletException: <h3>Validation error messages from tag library c</h3>tag = 'out' / attribute = 'value': An error occurred while parsing custom action attribute "value" with value "${car.defaultColor(car.carType)}": Encountered "(", expected one of ["}", ".", ">", "gt", "<", "lt", "==", "eq", "<=", "le", ">=", "ge", "!=", "ne", "[", "+", "-", "*", "/", "div", "%", "mod", "and", "&&", "or", "||"]
    Any Ideas?
    P.S. If it matters to you, I am using JSTL 1.0 and the code snippets above are actually within the value attribute of a <c:out value="" /> statement.

    How do you call a method that requires a parameter
    In scriplet code here is what I am trying to do
    <%= car.getDefaultColor(car.getCarType()) %>
    How do I do this in ELYou don't. EL is very strict in method signatures. All get methods must be public Type getProperty(void); And all set methods must be public void setProperty(Type t);
    So you will have to re-work your Bean so it does not need an argument to the get method (getDefaultColor()). Since you are calling another method out of car, you might re-write the getDefaultColor method as such:
      public Object getDefaultColor() {
        CarType ct = this.getCarType();
        //then do other stuff
      }If that isn't suitable, then provide a helper method that is used to set the current car type and then call the getDefaultColor:
      private CarType curCarType;
      public void setCurrentCarType(CarType ct) { curCarType = ct; }
      public Object getDefaultColor() {
        if (curCarType == null) throw new IllegalStateException("CarType must be set before getting color");
        //normal work using curCarType
    <c:set target="${car}" property="currentCarType" value="${car.carType}"/>
    <c:out value="${car.defaultColor}"/>It is better to do as little of the data manipulation (setting up the car type) in the JSP as possible, so the first option is better than the second. Also better then the second would be to set the current car type in a servlet or data access object (or wherever) from which your retreive the car to begin with. Manipulatig it in the JSP itself should be your last resort (to keep as much business logic out of the JSP as possible).
    Here is my guess (it generates the Exception
    described below)
    ${car.defaultColor(car.carType)}
    Here is the Exception I am getting:
    javax.servlet.ServletException: <h3>Validation error
    messages from tag library c</h3>tag = 'out' /
    attribute = 'value': An error occurred while parsing
    custom action attribute "value" with value
    "${car.defaultColor(car.carType)}": Encountered "(",
    expected one of ["}", ".", ">", "gt", "<", "lt",
    "==", "eq", "<=", "le", ">=", "ge", "!=", "ne", "[",
    "+", "-", "*", "/", "div", "%", "mod", "and", "&&",
    "or", "||"]
    Any Ideas?
    P.S. If it matters to you, I am using JSTL 1.0 and
    the code snippets above are actually within the value
    attribute of a <c:out value="" /> statement.

  • Calling a method that returns values in a map - using JSTL

    Hi I have a method within an object that returns a List for a particular category
    public List<String> getFieldsInCategory(String categoryName){
        return _categoryFieldsMap.get(categoryName); //This is a map that returns a list                                                             
      }Trying to call the above function in jsp, the object is available as "document",
    how do i pass a key to the above function to return a List.
       <c:forEach items="${document.fieldsInCategory('ABSTRACT')}" var="temp">How do i get the list by passing a string key to my method,
    please let me know how to go about this.
    Thanks

    JSTL can not directly call methods that take parameters.
    All it can do is access javabean properties - ie via the revealed get/set methods.
    You can fudge it by having a seperate variable to set:
    Map  _categoryFieldsMap;
    String category = null;
    public void setCategory(String category){
      this.category = category;
    public String getCategory(String category){
      return category;
    public List<String> getFieldsInCategory(){
        return _categoryFieldsMap.get(categoryName); //This is a map that returns a list                          
      }You would then do it like this in your JSP:
    <c:set target="document.category" value="ABSTRACT"/>
    <c:forEach items="${document.fieldsInCategory}" var="temp">
    ...The other alternative is to return the entire map to the page.
    EL accesses maps quite handily.
    so given a method that returns the map:
    public Map getCategoryFieldsMap(){
    return _categoryFieldsMap;
    then the expression: ${document.categoryFieldsMap.ABSTRACT} returns what you are after.
    Hope this helps,
    evnafets

  • Bind ADF table to EJB method that takes a argument (operation)

    Hi Oracles
    I can bind a ADF table to a EJB method that takes no arguments, and then JDeveloper calls the method a accessor. I would like to bind another ADF table to another EJB method that takes a argument, but there I have some problems. First of all JDeveloper will not allow this, can I work around that? Then obviously I have to pass the argument to this EJB method some how..?
    Do you guys have any way of fixing this? Is the only way to not bind the ADF table, and do it in code in the background, and how do I do this?
    Best regards
    Søren

    Thank you!
    I found it, and if I drag it to my JSP, it gives me these options:
    - Create Methods
    - ADF Link
    - ADF Button
    - ADF Menu Item
    - ADF Toolbar Button
    - ADF Image Link
    - Create Parameters
    - ADF Parameter Form
    I have one ADF table that is bound to a data control, and based on the selection on this table, I would like to show data in another table based on a EJB method that takes a id from the selected object from the first table. Either on the same JSP or on another JSP, whatever is easiests.
    Can you help me do this? Then I hope I learn something in the process :)
    Best regards
    Søren

  • How to call java method having array as argument from c++ ?

    Hello sir,
    how to call java method having array as arguments from c++;
    here is java code which is called from c++
    class PQR {
         public void xyz(int[] ia) {
         System.out.println("hi");
              for (int i = 0; i < ia.length; i++)
                   System.out.println(ia);
    suppose all jvm invocation is done...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    For someone well versed in java, C++ and JNI although tedious that should be obvious.
    For someone not well versed in all three it is going to be very difficult.
    Even for someone that does have knowledge in all of those areas coming up with a C++ interface that reflects that functionality in a dynamic way such that anyone is will to use it is going to be quite an adventure.
    At any rate to start building it you do exactly the same thing that you would in java.
    1. Extract everything in the jar via the zip package
    2. For each found instance extract all of the methods, return types, parameters, etc and build a description tree for each class.
    Doing all of that in C++ is going to take a LOT of code. If someone wanted an estimate from me it would take me 6 months to do it. And before I would even attempt it I would get them to explain to me in detail exactly how they thought they were going to use it when I was done because I can't see any reasonable way to do that.
    I left out the description tree itself. I suppose you could duplicate the entire reflection api in C++.
    Now perhaps if it was much, much more constrained, like to only those classes that implement a single interface then that would be more reasonable.

  • How to call a method in private section of a class in the public section

    Hi Everybody,
    i have written a method(meth1) in the private section of a class(C1).
    it is as follows
    class C1 definition.
    private section.
    methods: meth1 importing im_dt1 like tp1
                                             im_dt2 like tp2
                                             im_dt3 like tp3
                                             im_dt4 like tp4
                               returning value(re_dt1) like tp5.
    endclass.
    i have the final data that has to be displayed in internal table re_dt1.
    now my question is how to call  this method present in private section into public section and display the data present in re_dt1.
    Thanks,
    learning.abap.

    Hi,
    what you need is one public method being called at start-of-selection. Within this the private methods have to be called.
    The question is, why has the method for reading the database tables to be private? If you have only one private method reading all database tables the public method being called at start-of-selection will only consist of a call-method statement.
    This seems to be one call to much.
    The logic for reading the different database tables is hidden inside the class anyway.
    Is there any further logic reading the different database tables?
    Have always all table to be read? If not another approach would be one private method for each database table being called by a public method deciding which table has to be read:
    public section.
    methods get_data returning value(re_Dt1).
    private section.
    methods:
    get_table_a returning value(im_dt1),
    get_table_b returning value(im_dt2),
    get_table_c returning value(im_dt3),
    get_table_d returning value(im_dt4),
    combine_data importing im_dt1
                                    im_dt2
                                    im_dt3
                                    im_dt4
                            returning value(re_dt1).
    *- implementation of public method:
    method get_data.
      data: lt_dt1 ...
               lt_dt2,
               lt_dt3,
               lt_dt4.
    * here decide which tables have to be read:
    lt_dt1 = get_table_a( ).
    lt_dt2 = get_table_b( ).
    lt_dt3 = get_table_c( ).
    lt_dt4 = get_table_d( ).
    re_dt1 = combine_data( i_dt1 = lt_dt1
                                           i_dt2 = lt_dt2
                                           i_dt3 = lt_dt3
                                           i_dt4 = lt_dt4 ).
    endmethod.
    *- implementation of private methods
    method get_table_a.
    endmethod.
    method get_table_b.
    endmethod.
    method get_table_c.
    endmethod.
    method get_table_d.
    endmethod.
    method combine_data.
    endmethod.
    Regards
    Dirk

  • How to call a method from a separate class using IBAction

    I can't work out how to call a method form an external class with IBAction.
    //This Works 1
    -(void)addCard:(MyiCards *)card{
    [card insertNewCardIntoDatabase];
    //This works 2
    -(IBAction) addNewCard:(id)sender{
    //stuff -- I want to call [card insertNewCardIntoDatabase];
    I have tried tons of stuff here, but nothing is working. When i build this I get no errors or warnings, but trying to call the method in anyway other that what is there, i get errors.

    Can you explain more about what you are trying to do? IBAction is just a 'hint' to Interface Builder. It's just a void method return. And it's unclear what method is where from your code snippet below. is addNewCard: in another class? And if so, does it have a reference to the 'card' object you are sending the 'insertNewCardIntoDatabase' message? Some more details would help.
    Cheers,
    George

  • How to call a method defined in AM when I select any value in LOV

    Lets say there is a LOV. The scenario is as soon as I select any value in LOV, a method needs to be called which I have written in the AM. And the output of the method is displayed in a output text box.
    I am not able to understand how to call a method when the user selects any value in LOV.
    This is wht I did. I had created the binding for the method. Changed the autosubmit property of the LOV to True, and in the properties of the output box, in the partial submit trigger property, passed the ID of the LOV. But I didnt get any place where I need to call the method. I am also not able to drop an action listener on the LOV

    Hi,
    +"its showing an error(underlined in orange)."+
    Any reason you don't share this error with us? Anyway, here is how it goes
    1. LOV, set autosubmit="true" and configure a value change listener
    2. Expose the AM method as a method binding in the PageDef file
    3. In the value change listener:
    BindingContext bctx = BindingContxt().getCurrent();
    BindingContainer bindings = bctx.getCurrentBindingsEntry();
    OperationBinding method = (OperationBinding) bindings.get("name of method binding in PageDef");
    method.getParamsMap().put("argument name1", value1);
    method.getParamsMap().put("argument name2", value2);
    Object retVal = method.execute();
    if(!method.getErrors().isEmpty()){
      //handle errors
    else{
      //write retVal to the managed bean variable that is referenced by the outputText value property
      //PPR output text component
      ADFFacesContext.getCurrentInstance().addPartialTarget(outputTextRef);
    }Note that you may have to set clientComponent = "true" on the output text component
    Frank

  • How to call java method in jsp file?

    can anyone guide me or teach me how can i call the java method into the jsp file? do i need a main method to call it in? or just call the method that i need 2 use only??
    below is the coding that i did. one is java and another one is jsp. hope that someone can help me on it. Thanks!!!! Really appreciate it.
    Country Method.java
    package Test;
    import java.io.File;
    import com.db4o.*;
    import com.db4o.ObjectContainer;
    import com.db4o.ObjectSet;
    public class countryMethod {
         public final static String filename = "C:\\TestStore.yap";
         public String record;
         public int value;
         public String cName1;
         private static ObjectContainer db = Db4o.openFile(filename);
         public static void storeData() {
              //Delete existing data file
              new File(filename).delete();
              //Open Database
              db = Db4o.openFile(filename);
              //Add value into database
              Country c1 = new Country(100, "Malaysia");
              Country c2 = new Country(200, "Thailand");
              Country c3 = new Country(300, "Sing");
              Country c4 = new Country(400, "Japan");
              Country c5 = new Country(500, "Indian");
              db.set(c1);
              db.set(c2);
              db.set(c3);
              db.set(c4);
              db.set(c5);
              System.out.println("abc");
         public String getData() {
              String str = "";
              try {
                   //open database
                   ObjectContainer db = Db4o.openFile(filename);
                   //Create empty object
                   Country country = new Country(0,null);
                   //Object dataset
                   ObjectSet result = db.get(country);
                   //System.out.println(result.size());
                   while(result.hasNext()){
                        Country a = (Country)result.next();
                        record = a.getName();
                        value = a.getValue();
                        str = str +" | "+ value;
                        //System.out.println(str);
                        //System.out.println(a.getValue());
              }catch(Exception s){
                   s.printStackTrace();
              str = str +" | "+ record;
              return str;
         /*public int getValue(){
              return value;
    }and the jsp.
    <%@page import com.db4o.ObjectContainer%>
    <html>
    <head><title>Testing page</titile></head>
    <body>
    <jsp:useBean id="link" class = "Test.countryMethod" />
    <%=link.getData() %>
    </body>
    </html>

    i try on the easier that i can but still i have error displaying it
    here are the files
    package com;
    public class CountryPeople {
         public String name;
         private int value;
         public CountryPeople(String name, int value){
              this.name = "Eric";
              this.value = 2;
         public String getName() {
              return name;
         public int getValue(){
              return value;
    }JSP file will be
    <html>
    <head><title>Testing page</titile></head>
    <body>
    <jsp:useBean id="store" class="com.CountryPeople"/>
    <jsp:setProperty name="store" property="name" />
    <jsp:setProperty name="store" property="value" />
    <%= store.getName() %>
    <jsp:getProperty name="store" property="name" />
    <jsp:getProperty name="store" property="value" />
    </body>
    </html>JAVA File
    <html>
    <head><title>Testing page</titile></head>
    <body>
    <jsp:useBean id="store" class="com.CountryPeople"/>
    <jsp:setProperty name="store" property="name" />
    <jsp:setProperty name="store" property="value" />
    <%= store.getName() %>
    <jsp:getProperty name="store" property="name" />
    <jsp:getProperty name="store" property="value" />
    </body>
    </html>The end message is
    the error message
    at [org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         at java.lang.Thread.run(Unknown Source)
    Hope that you guys can me. Thanks

Maybe you are looking for