5 Replies Latest reply on Sep 16, 2008 2:39 PM by shadowcreeper

    Determine wich component called the ValueBinding method

    Gianfranco Zola Newbie

      Hi!

      I have a problem here. I must know in the backing bean, wich component called the getter method for a property. This is because multiple components on the form use the same getter method for it's property, and the return value should be created regarding the calling component.

      Eg.:

      <h:inputText value="#{bean.property}" id="input1"/>
      <h:inputText value="#{bean.property}" id="input2"/>
      <h:inputText value="#{bean.property}" id="input3"/>
      


      In the backing bean:

      public Object getproperty()
      {
       String component_id = SOMEHOW_DETERMINE_WICH_COMPONENT_CALLED_THIS_METHOD;
      
       if (component_id.equals("input1"))
       {
       return "this is for input1";
       }
       else if (component_id.equals("input2"))
       {
       return "this is for input2";
       }
       ... etc.
       // of course I will do here more complex processing, this is only for example.
      }
      


      I need this solution, because I use the same generic backing bean for all forms, and the forms are dinamically created runtime in the bean constructor. So I can not use dedicated properties, but it will be a huge advantage if I could use a general property getter, and must not code some complicated methods, to generate the initial/refreshed value for a component.

      Thanks in advance!

      Regards,

      Gizola