This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have an <h:selectOneListbox> in my xhtml file and when the user select a value I would like to display the selected value within an <h:inputText> below the page, or using a pop up or to another xhtml. I know that <h:inputText> component is used for retrieving data from the users, however i want to display it some way near to a <h:inputText> in order to give the opportunity to the users to perform some predicates e.g child > 12 (child is the selected value). But I didn't find a way to achieve that yet.
I was thinking that the reason is: UI components for User interface are in the Client side whereas the selected value after the selection of the value are in the Server side (myBean). Is it correct ?
UIComponent objects reside only on the server. They are rendered into HTML to provide the client View.
So you have 2 options.
1. Use AJAX so that when the parent control (selectOneListBox) is changed, an AJAX request updates the backing bean and fires an action that causes the backing property value of the inputText to change (you also have to inform the AJAX mechanism to re-render the inputText).
An IDE is no substitute for an Intelligent Developer.
setNewValue is an unfortunate choice for a Listener method name - it can be confused with legitimate property mutators, since it begins with "set". A better name would be something more like "selectItemsListener". Do not include "()" on the EL. JSF already knows that there's a listener method call and I think you're confusing it, since you've coded it as a no-argument method call.
Why the item ID "input" isn't resolvable I'm not sure. I have been shirking my studies on the f:ajax tag, although I can't do that much longer.
Joined: Mar 11, 2012
I tried a lot but I have the same problem, My xhtml file does not recognise the selectItemsListener. Always there is an unknown method selectItemsListener. Have I forgotten something else?
Converters are used to translate between binary and text formats. They are required because HTML is a text-only representation and therefore any binary data must be converted. Likewise, when you enter text into an HTML form control and JSF is backing that control with a binary property such as an "int", the converter manages that task as well.
If the selected converter cannot convert - for example, you typed the value "Fred" into a textbox mapped to a numeric property, a conversion error gets thrown.