-
1. Re: Determine wich component called the ValueBinding method
ilya_shaikovsky Sep 16, 2008 7:24 AM (in response to gizola)you should define actionListener on the components and get the action source from event.getComponent in listener.
-
2. Re: Determine wich component called the ValueBinding method
gizola Sep 16, 2008 8:03 AM (in response to gizola)
Hi!
Thanks for relpying.
ActionListener is not working for a couple of components, like inputText, outputLabel, etc.
So actionListener is only good solution for components, wich do some action. For value retrieval (like value for an imputtext or value for a selectonelistbox) it is not good.
Also the actionlistener is only called, when some action is performed on the component, but the value is accessed on first displaying the component, on rerendering the component, etc.
Regards,
Gizola -
3. Re: Determine wich component called the ValueBinding method
nbelaevski Sep 16, 2008 8:51 AM (in response to gizola)Gizola,
Value expressions do not have component context, so looks like it is not possible to determine which component is accessing it now. What about different expressions referring to the same method? The simplest variant is to use map and request data from it using component id, e.g.:<h:inputText value="#{bean.propertyMap['input1']}" id="input1"/> <h:inputText value="#{bean.propertyMap['input2']}" id="input2"/> <h:inputText value="#{bean.propertyMap['input3']}" id="input3"/>
-
4. Re: Determine wich component called the ValueBinding method
gizola Sep 16, 2008 9:27 AM (in response to gizola)Hi!
I had also the idea to use a HashMap with a String key (component id), but than I dropped it, because so I can get back only the object stored in the HashMap, but I can not make any processing, before I give the value back to the component.
But may be I can figure out some other method to use a Map to store the components values by component ID.
Thanks for the idea.
One question: will be there maybe implementation for component context in value expressions? Or is there any way to override some class or method to have control how the value expression method is called? (maybe put the component to the sessionmap before calling the method?)
Regards
Gizola -
5. Re: Determine wich component called the ValueBinding method
shadowcreeper Sep 16, 2008 2:39 PM (in response to gizola)You can extent Map to do processing.
Ilya pointed me to some code that does just that...
The javax.faces.UIComponentBase class has a getAttributes method which returns a javax.faces.component._ComponentAttributesMap which overrides the get() method to do EL translation.
You could do something similar.