| Author |
Populating the form on ValueChangeListener event
|
M Yuvi
Greenhorn
Joined: Mar 19, 2008
Posts: 9
|
|
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.
|
 |
Brajendra Mathema
Ranch Hand
Joined: Jun 02, 2009
Posts: 39
|
|
hi M Yuvi,
you can bind the username value to the corresponding inputtext in the backing bean and then set the value of the binding element
thankyou
|
 |
Vishal Chaudhry
Greenhorn
Joined: Dec 16, 2009
Posts: 7
|
|
|
Have you provided getter and setter method for userName property in the bean?
|
 |
 |
|
|
subject: Populating the form on ValueChangeListener event
|
|
|