Thanks for replying. from activate i mean to populate it. like if user select USA than the city list should populate cities in it. and it should be done onchange. i have not worked on ajax yet so i do not have any idea about it. so if you can provide me any solution for jsf i be very glad.
or
if there is any tutorial available for ajax solution so let me know it.
JSF<h:form>
<h:selectOneMenu value="#{myBean.selectedCountry}" onchange="submit();" valueChangeListener="#{myBean.loadCities}">
<f:selectItems value="#{myBean.selectCountries}" />
</h:selectOneMenu>
<h:selectOneMenu value="#{myBean.selectedCity}">
<f:selectItems value="#{myBean.selectCities}" />
</h:selectOneMenu>
</h:form>
MyBeanpublic void loadCities(ValueChangeEvent event) {
// Here you can get the selected country from selectedCountry and then populate selectCities.
}
Thanks for this solution. I'll try it.
Now i am facing an other problem. that is i am using <h: message> tag to show error message if user do not enter value for any field. i have three button on my form .
1. Save
2. Clear
3. Edit
I want that <H:message will only validate when i press save button. but it also validate when i press clear or edit. so do you have any idea about it.>
Check this:
<h:outputText value="Ward ID" />
<h:selectOneMenu id="wardId" value="#{WardController.id}" onchange="submit();" valueChangeListener="#{WardController.getBedValues}">
<f:selectItems value="#{WardController.wardList}" />
</h:selectOneMenu>
<h:outputText value="Bed ID" />
<h:selectOneMenu id="bedId" value="#{WardController.phone}" required="true">
<f:selectItems value="#{WardController.bedList}" />
</h:selectOneMenu>
my bean is like this :
public void getBedValues(){
try{
WardManagerDAO dao = new WardManagerDAO();
List allList = dao.showBeds(id);
bedList = new SelectItem[allList.size ()];
for(int i= 0;i<allList.size();i++){
WardDetail wards = (WardDetail)allList.get(i);
bedList=new SelectItem (wards.getBedId());
}
}
when i change the value of first list the following error occur:
javax.servlet.ServletException: getBedValues: com.obaidnoor.hms.controller.WardsController.getBedValues(javax.faces.event.ValueChangeEvent)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)
With root cause :
javax.faces.el.MethodNotFoundException: getBedValues: com.obaidnoor.hms.controller.WardsController.getBedValues(javax.faces.event.ValueChangeEvent)
com.sun.faces.el.MethodBindingImpl.method(MethodBindingImpl.java:206)
com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:124)
javax.faces.component.UIInput.broadcast(UIInput.java:492)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:249)
javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:343)
com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:78)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
It say that method not found . but i have this method in my bean.>
The error:javax.faces.el.MethodNotFoundException: getBedValues: com.obaidnoor.hms.controller.WardsController.getBedValues(javax.faces.event.ValueChangeEvent)
Your method:public void getBedValues(){
...
}
getBedValues(javax.faces.event.ValueChangeEvent) != getBedValues()
Please reread the errormessage and my code =)