I need to return the selected value to the bean for further processing but its returning null value .
<h:form>
<h:panelGrid columns="1">
<p:outputLabel id="state" value="State Name"></p:outputLabel>
<p:selectOneMenu id="statemenu" style="width:300px;"
value="#{MenuBean.state}">
<f:selectItem itemLabel="Select One"></f:selectItem>
<f:selectItems value="#{MenuBean.stateList}"></f:selectItems>
<p:ajax listener="#{MenuBean.stateChange}" update="dist"
process="@this" immediate="true"></p:ajax>
</p:selectOneMenu>
<br></br>
<p:outputLabel value="District"></p:outputLabel>
<p:selectOneMenu id="dist" style="width:300px;"
value="#{MenuBean.district}">
<f:selectItem itemLabel="Select One"></f:selectItem>
<f:selectItems value="#{MenuBean.districtList}"></f:selectItems>
</p:selectOneMenu>
</h:panelGrid>
<h:panelGrid style="position:relative; left:165px" columns="2"
cellpadding="2" cellspacing="2">
<p:commandButton value="Reset"
style='font-family: font-family : Baskerville, "Baskerville Old Face",
"Hoefler Text", Garamond, "Times New Roman", serif;;
font-size: 13px; font-weight: normal'></p:commandButton>
<p:commandButton value="Submit" immediate="true"
action="#{MenuBean.getValues}"
style='font-family: font-family : Baskerville, "Baskerville Old Face",
"Hoefler Text", Garamond, "Times New Roman", serif;;
font-size: 14px; font-weight: normal'></p:commandButton>
</h:panelGrid>
</h:form>
and the backing beaning is
private String state;
private String district;
private Map<String,String> StateList = new HashMap<String,String> ();;
private Map<String,String> DistrictList = new HashMap<String,String>();
public MenuBean() {
System.out.println("Entering the Constructor");
StateList = DBConnector.StateList();
// DistrictList = DBConnector.DistrictList();
}
public void stateChange() {
DistrictList = DBConnector.DistrictList();
}
public void getValues() {
System.out.println("getting the values");
System.out.println(getState());
System.out.println(getDistrict());
}
I have edited the code snippet i guess it will give you a insight on it .