Reputation: 31
How to get value from "itemvalue" attribute of 'f:selectItem itemLabel="Request Posting" itemValue="1" ' in a managed Bean in jsf ?
Upvotes: 0
Views: 877
Reputation: 1108632
JSF will just set it in the property behind value
attribute of the UISelectOne
or UISelectMany
component wherein you are using this <f:selectItem>
as child.
E.g.
<h:selectOneMenu value="#{bean.someProperty}">
<f:selectItem itemLabel="Request Posting" itemValue="1" />
...
</h:selectOneMenu>
<h:commandButton value="submit" action="#{bean.submit}" />
It'll during the invoke action phase (e.g. in command button action method) just be available as someProperty
.
private String someProperty; // +getter+setter
public void submit() {
System.out.println(someProperty); // Look, JSF has already set it!
}
Upvotes: 1