如果当前选择无效,有没有办法自动将selectOneMenu的值设置为null?
<h:panelGroup id="locationInformationPanel">
<h:selectOneMenu id="pulldown1">
<f:ajax listener="#{LocationSelector.siteNameChangeListener}"
render="locationInformationPanel" execute="@this"/>
<f:selectItem itemLabel="" itemValue="" noSelectionOption="true"/>
<f:selectItems value="#{LocationSelector.siteNames}"/>
</h:selectOneMenu>
<h:selectOneMenu id="pulldown2">
<f:ajax listener="#{LocationSelector.buildingChangeListener}"
render="locationInformationPanel" execute="@this"/>
<f:selectItem itemLabel="" itemValue="" noSelectionOption="true"/>
<f:selectItems value="#{LocationSelector.buildings}"/>
</h:selectOneMenu>
</h:panelGroup>
public void siteNameChangeListener(AjaxBehaviorEvent e) {
String selectedSiteName = getSelectionsFromEvent(e);
updateBuildings(selectedSiteName);
}
注意:这些菜单没有任何&#34;值&#34;绑定到它们的字段但是,即使我绑定它们,它仍然会发生。绑定字段最终保存第一个无效值
答案 0 :(得分:0)
我不确定这是不是&#34;对&#34;方式,但我添加了'pulldown2&#39;到pulldown1中的ajax标签的execute属性,它起作用了:
<h:selectOneMenu id="pulldown1">
<f:ajax listener="#{LocationSelector.siteNameChangeListener}"
render="locationInformationPanel" execute="@this pulldown2"/>
有关此方法的任何反馈意见?