在选择州并根据国家/地区选择填充州下拉列表时填充城市下拉列表;但是,它不是这样做的。
问题是当根据国家状态选择的国家/地区填充状态dropdwon但是当我从州dropdwon列表中选择状态时它没有显示填充城市dropdwon
实际问题是当我选择状态时,状态变量中没有设置状态值
以下是代码:
JsfPage
<p:selectOneMenu id="countrydrop" value="#{user.country}" >
<f:ajax id="countryajex" listener="#{user.statesbycontry()}" render="statedrop"/>
<f:selectItem itemLabel="Select Country" itemValue="" noSelectionOption="true" />
<f:selectItems value="#{user.allcontry()}" />
</p:selectOneMenu>
<p:selectOneMenu id="statedrop" value="#{user.ustate}" >
<p:ajax event="change" id="stateajex" listener="#{user.citybystate()}" update="citydrop" />
<f:selectItem itemLabel="Select State" itemValue="" noSelectionOption="true" />
<f:selectItems value="#{user.statelist}"/>
</p:selectOneMenu>
<p:selectOneMenu id="citydrop" value="#{user.city}" >
<f:selectItem itemLabel="Select City" itemValue="" noSelectionOption="true" />
<f:selectItems value="#{user.citylist}" />
</p:selectOneMenu>
jsfManagedBean
String country;
String state;
String city;
List<String> statelist;
List<String> citylist;
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public List<String> getStatelist() {
return statelist;
}
public void setStatelist(List<String> statelist) {
this.statelist = statelist;
}
public List<String> getCitylist() {
return citylist;
}
public void setCitylist(List<String> citylist) {
this.citylist = citylist;
}
public List<String> allcontry(){
return od_user_bean.allcountries();
}
public void statesbycontry(){
//Method tested Working well
statelist = od_user_bean.findstatesbycontries(country);
}
public void citybystate(){
System.out.println("State="+state);
if(state != null)
//Method tested Working well
citylist=od_user_bean.findcitybystate(state);
}