I have problem with populating the form with data, upon selecting a value in the list box. Upon selecting the list box, by handling the ValueChangeListener, I want to populate the form with the corresponding data.
Below is the
JSP
...
<h:selectOneMenu valueChangeListener="#{user.fetchData}" onchange="submit();" value="#{user.userId}">
<f:selectItems value="#{user.userIdList}" />
</h:selectOneMenu>
<h:inputText value="#{user.userName}" />
<h:commandButton action="#{user.submit}" value="click"/>
...
The corresponding managed bean is ...
public class User {
private int userId;
private List<SelectItem> userIdList=new ArrayList<SelectItem>();
private
String userName;
// getter and setter methods
public void fetchData(ValueChangeEvent event){
// some logic to assign the userName
userName="C";
}
}
Upon selecting a particular userId, the corresponding userName is displayed in the form if the "disabled" property of userName UI component is set to "true". Otherwise, the data is not displayed in the form. However my requirement is, the corresponding data should be displayed and the user should be allowed to edit the details and store it on submit.
Please help me in resolving this.