A tricky way to twick ValueBinding language to bind a method call

Here is the scenario:
I'd like component can bind value to method call(with parameters) to a java instance, of course including backingBean.
I wish this solution would be useful, especially when you are working in iteration component such as ForEach, TreeView or DataTable, EL ValueBinging language might be too restricted to complex expression. This way, you can pass iteration items as parameters into a method can and return a value to you page by valuebinding language
In JSP:
    <h:outputText value="#{Page1.callHelper[Page1]['targetMethod']['James'][Page1.callEnd]}"/>In PageBean:
     public String targetMethod(String name){
         return "Hello, " + name +"!";
    private CallHelper callHelper = new CallHelper();
     public CallHelper getCallHelper() {
          return callHelper;
     public void setCallHelper(CallHelper callHelper) {
          this.callHelper = callHelper;
     private CallEnd callEnd = new CallEnd();
     public CallEnd getCallEnd() {
          return callEnd;
     public void setCallEnd(CallEnd callEnd) {
          this.callEnd = callEnd;
     }Util classes:
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class CallHelper extends LinkedHashMap {
     private CallHelper parent;
     public Object get(Object key){
          if(key instanceof CallEnd)return getRoot().methodCall();
          else{
               Object value = super.get(key);          
               if(value == null){
                    value = new CallHelper();
                    put(key, value);
                    ((CallHelper)value).parent = this;
               return value;
     public boolean containsKey(Object key){
          return true;
     public boolean realContainsKey(Object key){
          return super.containsKey(key);
    protected CallHelper getRoot(){
         CallHelper root = this;
         if(root.parent==null)return root;
         else return root.parent.getRoot();
     protected Object methodCall(){
          Object result = null;
         List callParameters = new ArrayList(2);
         listCallParameters(callParameters, this);
         if(callParameters.size()>1){
              Object instance = callParameters.get(0);
              String methodName = callParameters.get(1).toString();
              List methodParameters = new ArrayList();
              for(int i=2; i<callParameters.size(); i++){
                   methodParameters.add(callParameters.get(i));
              Method method = findMethod(instance, methodName, methodParameters);
              if(method != null){
                   try {
                         result = method.invoke(instance, methodParameters.toArray());
                    } catch (IllegalArgumentException e) {
                    } catch (IllegalAccessException e) {
                    } catch (InvocationTargetException e) {
          this.clear();
          return result;
     private void listCallParameters(List list, Map map){
          if(map==null || !map.keySet().iterator().hasNext())return;
          Object key = map.keySet().iterator().next();
          if(key instanceof CallEnd)return;
          list.add(key);
          listCallParameters(list, (Map)map.get(key));
     private Method findMethod(Object instance, String methodName, List parameters){
          Method result = null;
          Method[] methods = instance.getClass().getMethods();
          for(int i=0; i<methods.length; i++){
               if(methods.getName().equals(methodName)){
                    System.out.println(methodName);
                    Class[] paraClasses = methods[i].getParameterTypes();
                    if(paraClasses.length==parameters.size()){
                         boolean match = true;
                         for(int j=0; j<paraClasses.length; j++){
                              if(parameters.get(j)!=null && !paraClasses[j].isInstance(parameters.get(j))){
                                   match = false;
                                   break;
                         if(match){
                              result = methods[i];
                              break;
          return result;
public class CallEnd {
Improvement:
Anyone can make it thread safety and bind callhelper and callend directly to FacesContext properties rather than each backingBean.
Have fun!
And feel free to contect me at:
[email protected]
[email protected]

You must seperate your parameter preparing and action method calling for sure.
It depends on what kind of parameters you need to pass in:
1. If action method is bound to several buttons, and it just wants to know which button was clicked, you can set actionListener to prepare it for you. Because the event includes the information you need.
2. For other kinds of parameters, you can use ValueBinding Language to bind parameter values to backingBean, then the action method(without parameters) can pick parameters up from backingBean.

Similar Messages

  • Any way to get the value of attribute in method call

    Hi
    I am using ADF 11.1.1.3 and dynamic tab shell.
    I am trying to download file form my page fragment.
    *<af:commandLink text="#{row.bindings.element.inputValue.FileName}"*
    id="viewFileInfo"
    *actionListener="#{backingBeanScope.backing_fragments_auditChecklistUploadedFilesInfo.getFileInformation}">*
    *<af:fileDownloadActionListener filename="#{row.bindings.element.inputValue.FileName}"*
    *contentType="#{row.bindings.element.inputValue.MimeType};"*
    *method="#{backingBeanScope.backing_fragments_auditChecklistUploadedFilesInfo.getFile}"/>*
    *</af:commandLink>*
    I need the value of the filename *#{row.bindings.element.inputValue.MimeType};* inside my method *method="#{backingBeanScope.backing_fragments_auditChecklistUploadedFilesInfo.getFile}" D oyou have any idea how can i achieve the same..
    *Scenerio* -
    I have a table and inside a table filename column is a command link. And on click of the link i fetch the data from db for that file thats why i need file name inside **method="#{backingBeanScope.backing_fragments_auditChecklistUploadedFilesInfo.getFile}"* ..
    Any idea?

    Did you try the above code ?
    toolbean.finditerator does the following
        public static BindingContainer getBindingContainer() {
            return (BindingContainer)getValueExpression("#{bindings}");
        public static DCBindingContainer getDCBindingContainer() {
            return (DCBindingContainer)getBindingContainer();
        public static DCIteratorBinding findIterator(String name) {
            DCIteratorBinding iter =
                getDCBindingContainer().findIteratorBinding(name);
            if (iter == null) {
                throw new RuntimeException("Iterator '" + name + "' not found");
            return iter;
        }If you tried the above code is the iterator null ?
    What code are you using in your bean ?

  • Is there any way to toggle between languages in 10.5.8?

    I write emails in Japanese {Hiragana and Kanji) a lot but I need to frequently transfer between English and Japanese for that.
    On an older OSX version there used to be a way to toggle between selected languages using the space bar and another key (I think it was the Apple key) but that doesn't work in 10.5.8.
    Is there another way to toggle selected languages in 10.5.8?

    Someone (called rick) made a video tip on this.
    http://www.tiptrickmod.com/mac/how-to-switch-between-languages/

  • Is there any way to set global language as english for users  in portal

    Hi,
    Is there any way to set global language as english for all the users  in portal (for all the screens,applications etc) irrespective of browser settings,language in jco,user settings in backend .
    the reason why i am asking is we are implementing global implementation project and for some users in switzerland because of their browser is not english they are getting language other than english.we dont want to ask each user to change their browser language.we just want to force the portal to display content only in english
    Thanks
    Bala Duvvuri

    Hi ,
    You can add property  'request.mandatorylanguage=<your_language>'
    and property  'request.mandatorycountry'
    on file 'prtDefault.properties' located in :
    ..server0\apps\sap.com\irj\servlet_jsp\irj\root\WEB-INF\portal\system\properties\prtDefault.properties
    Then restart the server.
    See :
    http://help.sap.com/saphelp_nw70/helpdata/EN/42/938297a5061d69e10000000a1553f6/frameset.htm
    Regards,
    Gilad

  • HT1657 I live in switzerland and I can only rent movies in german language. Is there a way to change the language to the original language when renting?

    I live in Switzerland and I can only rent movies in german language...is there a way to change the language of the movie I rent from Itunes back to original language?

    Hi Zanaro,
    It is an Apple isuue same as when you want to buy or download from the iTunes store.
    I bought and registered (also credit card from Australia) mi iPhone 4s
    Now when I came to Switzerland I should have NOT used my Australian details but registered everything here in Switzerland with Swiss credit card and probably a swiss email account.
    My problem is opposite to yours, I can only download movies in English!!!!
    What Apple could have done at least is give an option on undertittles so at least some movies are understud. It is no problem for myself but when I have friends over that do not understand the language we have problems.
    I have had talks in Apple stores in Zuerich also in smaller Apple outlets, they all know about it as it is a common not problem but nuicance with Apples.
    I hope I could shed some light to your problems but I think we can only hope that Apple will change theyr attidude to this **** situation.
    Pebi

  • Expression Language - Beyond binding (mini-tutorial)

    Expression Language - Beyond binding (mini-tutorial)
    Creator has a binding logic that is very easy to use. You right click on a component and choose which properties to bind onto your backing beans. Then you manipulate the backing bean property to change the bound property of your component. Or users input information into your app and the component writes through that input to your backing bean. It's cool.
    But sometimes you find yourself binding things to other things and you wonder if this is the simplest way to do things. A classic example is the old "how do I highlight a row of this table based on some datafield?" question. This has been answered by Tor Norbyte and the method works but to me it looks a little disjointed and clumsy.
    The classic solution involves binding your tableColumn's style property to a String type bean. Then inside the bean you write the logic that selectively returns a "background-color:'yellow'" string or something similar (Tor used css). The problem is that within the bean you still need to figure out what is the current row of your table. To do this you need to invoke and EL expression from the Java code which, if you were trying to avoid EL, is circular logic. Worse still, imagine you want to color columns separately.
    Here's an alternative solution using only Expression Language. It's self contained, easy to debug and maintain and once you've taken a look at it is pretty simple.
    Here's the JSP tag that does this:
    <ui:tableColumn binding="#{myHomePage.tableColumn7}"
    headerText="Expired" id="tableColumn7" 
    style="#{currentRow.value['expired']>0?'background-color: red':''}">To make it work I had to manually type the expression in the JSP file. The property editor will work with some EL statements but not all. Sometimes it mangles your EL expression and this can take a bit of debugging. <tip>Use the JSP editor...</tip>
    The bit I had to manually type is this:
    style="#{currentRow.value['expired']>0?'background-color: red':''}"All it does is check if some field in my TableRowGroup called 'expired' is greater than zero and if so highlight the cell. The construction is #{[condition]?[true value]:[false value]}
    You can also mix text and expressions in an EL expression:
    <ui:staticText ....  text="#{SessionBean1.userName}'s Home Page"/>If "Milo" is logged in he'll see "Milo's Home Page" where I placed this static text component.
    Here's an example I've got that's part of a Button tag in my JSP:
    visible="#{currentRow.value['d2.ReplacedBy']!=null}"In this case I don't want users pressing the button if the field is null, so I hide it for rows where the field is null.
    Bean or EL?
    Well strictly speaking it's not either or! In order for a Bean to be bound to a component you need an EL expression! So the question is do you implement you logic in a bean or an EL? Well that's pretty easy -- if the logic is simple and can be expressed in one line then use an EL only. Advantages: less dependencies and Bean properties floating around. If the logic is more complex use a backing bean and simple binding.
    More to explore
    Tor's blog entry:
    http://blogs.sun.com/roller/page/tor/20050113#creator_how_to_highlight_specific
    Winston's Blog entry
    http://blogs.sun.com/roller/page/winston?entry=setting_table_column_style
    [How do I add row numbers to a table?]
    http://forum.sun.com/jive/thread.jspa?threadID=112916&tstart=0
    [How do I use EL to bind to an Object's public property or field?]
    http://forum.sun.com/jive/thread.jspa?threadID=112434&tstart=0
    Addendum 1-Dec-06 Highlighting every 2nd row in a table
    The above thread on how to add row numbers to a table also exposes a pretty simple method to highlight every nth row in a table (a fairly common request)
    Something like this should work:
    <ui:tableColumn ...... style="#{currentRow.tableRow.rowId%2==1?'background-color: yellow':''}">Message was edited by:
    yossarian

    Hi Yossarian,
    Thanks for posting the simple but elegant solution. I liked the solution.
    To make it work I had to manually type the expression in the JSP file.
    The property editor will work with some EL statements but not all.
    Sometimes it mangles your EL expression and this can take a bit of
    debugging.Please file a bug against this at
    http://www.netbeans.org./community/issues.html
    Use visualweb as the sub category.
    Thanks
    - Winston
    http://blogs.sun.com/winston

  • Is there a way to gift an app with the billing method as store credit

    I want to gift 4 apps to my friend but i dont have a credit/debit card becuase im a kid. Is there a way to gift the apps when the billing method is store credit like a itunes giftcard?

    No.
    You CANNOT gift using your balance AT ALL.
    No matter how you ask;  you cannot gift with your balance.
    You can use your balance for your own purchases only.

  • My wife and I each have our own apple ID's which we use on our own iPhones and iPads. We share an iMac. Is there a way of enabling Facetime on the iMac to accept calls to either of our IDs without the need to login as that particular user?

    My wife and I each have our own apple ID's which we use on our own iPhones and iPads. We share an iMac. Is there a way of enabling Facetime on the iMac to accept calls to either of our IDs without the need to login as that particular user?

    no, when using facetime you log in with the apple id you want people to reach you at, so unless you both agree to share one apple id for all the facetime you do, it will be necessary for you to logout and login each time you use the application.

  • I have a ipod touch 2nd generation 8gb 4.2.1 im new to itunes i made a itunes account but it says i need a payment method is there anyway i can use my paypal if not is there a way to not have to use a payment method for itunes store please help ty

    i have a ipod touch 2nd generation 8gb 4.2.1 im new to itunes i made a itunes account but it says i need a payment method is there anyway i can use my paypal if not is there a way to not have to use a payment method for itunes store please help ty

    Create a NEW account using these instructions. Make sure you follow the instructions. Many do not and if you do not you will not get the None option. You must use an email address that you have not used with Apple before.
    Creating an iTunes Store, App Store, iBookstore, and Mac App Store account without a credit card
    Using those instructions you may also be able to select PayPal if that is allowed in your country.

  • I know the iphone 4s can turn off the vibrate for all sounds, but is there a way to keep the vibration on for just phone calls (with the ringtone also on) but off for everything else?

    I know the iphone 4s can turn off the vibrate for all sounds, but is there a way to keep the vibration on for just phone calls (with the ringtone) but off for everything else?

    Short answer: No.  Long answer: Nope
    http://manuals.info.apple.com/en_US/iphone_user_guide.pdf
    WYSIWYG   No hidden settings.
    If you want to suggest this to Apple:
    http://www.apple.com/feedback/iphone.html
    Message was edited by: modular747

  • Is there a way to see specific times and duration of phone calls?

    Is there a way to see specific times and duration of phone calls?

    Tap the phone button, then Recents. You see a list of the recent calls and can tap the arrow to the right of the name/number. That should give you the time and duration.

  • Is there any way to contact support by email because I cannot call them by phone and Thanks

    good day all, Is there any way to contact support by email because I cannot call them by phone and Thanks.

    It may vary by location but when I click on the Get Started button in http://www.apple.com/support/contact/ I get the following on the next page.
    Get help where you are.
    Choose a product and we’ll connect you to an expert by phone, chat, email, and more.

  • 10.1.2, EZ way to check method calls before I change and break them.

    Is there a way in JDeveloper to see what methods call a certain method (incase I make changes, I don't break several pages)?

    Well if you would have upgraded to JDeveloper 10.1.3 or 11g you would have had the find usages menu option to help you with this.
    Why are you still using 10.1.2?

  • What is the best way to practice SQL language?

    I’m new in database world and want to practice SQL language. I’ve been playing around with Oracle XE, but I realized it’s not very practical to play around with SQL using XE since its sql editor is not user friendly to debug the script. I’m trying to build schemas from scratch and play around with it using SQL. What is the best way to do this?
    Thanks in advance

    Valerie Debonair wrote:
    I’m new in database world and want to practice SQL language. I’ve been playing around with Oracle XE, but I realized it’s not very practical to play around with SQL using XE since its sql editor is not user friendly to debug the script. I do not think that is a valid criticism at all. The basic tools needed to learn SQL is SQL*Plus and a willingness to learn.
    There is no "+debugging+" for SQL either... except to break it into simpler steps, testing that... and perhaps using "+explain plan+" to get the execution plan.
    Granted that SQL*Plus is not the best tool for displaying data... but then learning SQL should be done using small data sets (not too many columns and few rows) - as even a small data set can represent all the data model complexities needed for learning SQL.
    The examples you use, the test tables and the practical exercises used in the learning process are by far more important how "pretty" the tool being used is.
    FWIW, I do 99% of all my SQL work and PL/SQL development using SQL*Plus - it is a very capable tool.

  • Is there any way to change the language in the iTunes/MacApp Store but still having a credit card connected to the stores "in a different languauge?

    Hi
    I'm living in Germany and I've got a German credit card connected to the stores (iTunes and MacApp) but I'd like to change the language to either English or Swedish. This way I beleive that I would be able to rent movies in another language than German on my Apple TV 2.
    Is this possible somehow?
    (When I change the language I need to have a credit card registred in the contry of that language)

    I saw that I wasn't the first person with this problem.

Maybe you are looking for

  • Hyperlinks in "organizational chart" not converting

    I have tried using the MS office "organization chart" (insert-> picture-> organization chart)function in word, excel, and ppt to make a drawing tree with hyperlinks. All of the links are lost when I convert to PDF. I also tried using VISIO to create

  • Dynadock Extended Window Settings Problem

    I am using a Dynadock PA3541U-2PRP and am having problems with the display settings attached to it. For some reason anytime I restart or lock/unlock the desktop the screen goes from extended mode back to mirror mode. According to the manual I should

  • Unable to insert row into table.

    hi all, here i am using oracle apex 3.2.0.0.0.27 version. i am unable to insert a row in the database table.when i press a save button i get an error is 0.07: 0.08: S H O W: application="132" page="4" workspace="" request="" session="3286250612369434

  • Gantt chart issue

    Hi, We are using SAP PPM 5.0 (cProject), unable to display the Gantt chart. Kindly suggest me what setting need to done to display Gantt chart. In URL for created project if I click for Graphical tab to display gantt chat, it just through out JAVA sy

  • IPhoto Clone repair tool - Where is it?

    Since upgrading to iPhoto '11 I have found the programme to "de-noise" and "enhance" my photos so well that the only artifacts left in my scanned photographs of many years ago contain only a few specks of dust that show up as white blobs. In previous