我有以下两个下拉。我想下拉A项目更改以填充下拉B.这工作正常,但问题发生在提交下降 down B为null,我得到一个null验证错误。我能做错什么?
<h:form id="set_up_form">
<p:messages id="infor" showDetail="false" closable="true"/>
<p:panelGrid columns="2" id="panel_grid_id">
<h:outputLabel value="Select Group A"/>
<p:selectOneMenu styleClass="font" id="group_list" value="#{myBean.group_A_id}" required="true" requiredMessage="Group Not Selected">
<f:selectItem itemLabel="--SELECT REVENUE GROUP--" itemValue="#{null}"/>
<f:selectItems value="#{myBean.groupA}"/>
<f:ajax render="sub_group_list"/> when I remove this tag and hand code group_A_id in getGroupB() form is submitted successfully
</p:selectOneMenu>
<h:outputLabel value="Select SubGroup"/>
<p:selectOneMenu styleClass="font" id="sub_group_list" value="#{myBean.group_B_id}" >
<f:selectItem itemLabel="--SELECT Group B--" itemValue="#{null}"/>
<f:selectItems value="#{myBean.groupB}"/>
</p:selectOneMenu>
<p:commandButton update="set_up_form" icon="ui-icon-plus" id="btnregister" value="Configure Revenue" action="#{mybean.savevalues}"/>
</p:panelGrid>
</h:form>
这是我的Managed Bean
public class MyBean {
private long group_A_id;
private long group_B_id;
// getter and setter
public Map<String, String> getGroupA() {
Map<String, String> map = new LinkedHashMap();
List<GroupA> grp = DBDao.getGroupARecords();// all values need to be populated
for (GroupA g : grp) {
String groupdId = "" + g.getId();
String groupName = g.getName().toUpperCase();
map.put(groupName, groupdId);
}
return map;
}
public Map<String, String> getGroupB() {// values depends on group_id selected from group A dropdown
Map<String, String> map = new LinkedHashMap();
List<GroupB> grp = DBDao.getGroupARecords("select from TableB where group_A_id='" + group_A_id + "'");// all values need to be populated
for (GroupB g : grp) {
String groupdId = "" + g.getId();
String groupName = g.getName().toUpperCase();
map.put(groupName, groupdId);
}
return map;
}
public void saveConfigs() {
System.out.println("Successfully Processed" + group_A_id + ":" + group_B_id);
}
}