Jsf 根据上一个p:SelectOne菜单值的输入,生成所需的多选下拉值
我想创建一个JSF应用程序。在应用程序中,用户将有两个下拉列表 如果用户从第一个下拉列表中选择国家/地区/值3,则需要从multiselect中选择选项Cancun/值6 如何实现这一点Jsf 根据上一个p:SelectOne菜单值的输入,生成所需的多选下拉值,jsf,Jsf,我想创建一个JSF应用程序。在应用程序中,用户将有两个下拉列表 如果用户从第一个下拉列表中选择国家/地区/值3,则需要从multiselect中选择选项Cancun/值6 如何实现这一点 从数据库中填充国家列表 身份证名称 美国-C 加拿大-N 墨西哥-C 城市名单 纽约(可选) 芝加哥(可选) 西雅图(可选) 多伦多(可选) 安大略省(可选) 坎昆[必选] 蒂华纳(可选) 在第二个下拉列表中,我们将确保该选项是选中的/必须选择的项 更新 我已经按照建议做了必要的修改,但不起作用 <
从数据库中填充国家列表
身份证名称
- 纽约(可选)
- 芝加哥(可选)
- 西雅图(可选)
- 多伦多(可选)
- 安大略省(可选)
- 坎昆[必选]
- 蒂华纳(可选)
<h:form>
<p:growl id="msgs" showDetail="true" skipDetailIfEqualsSummary="true" />
<p:panel header="Tranfer Destination" style="margin-bottom:10px;">
<h:panelGrid columns="2" cellpadding="5">
<p:outputLabel for="country" value="Country: " />
<p:selectOneMenu id="country" value="#{dropdownView.country}" style="width:150px" required="true" binding="#{country}">
<f:selectItem itemLabel="Select Country" itemValue="" noSelectionOption="true" />
<f:selectItems value="#{dropdownView.countries}" />
</p:selectOneMenu>
<p:outputLabel for="city" value="City: " />
<p:multiSelectListbox id="city" value="#{dropdownView.city}" style="width:150px" required="#{not empty param[country.6]}">
<f:selectItem itemLabel="Select City" itemValue="" noSelectionOption="true" />
<f:selectItem itemLabel="New York" itemValue="1"> </f:selectItem>
<f:selectItem itemLabel="Chicago" itemValue="2"> </f:selectItem>
<f:selectItem itemLabel="Seattle" itemValue="3">
</f:selectItem>
<f:selectItem itemLabel="Toronto" itemValue="4"> </f:selectItem>
<f:selectItem itemLabel="Ontario" itemValue="5"> </f:selectItem>
<f:selectItem itemLabel="Cancun" itemValue="6"> </f:selectItem>
<f:selectItem itemLabel="Tijuana" itemValue="7"> </f:selectItem>
</p:multiSelectListbox>
</h:panelGrid>
<p:separator />
<p:commandButton value="Submit" update="msgs" action="#{dropdownView.displayLocation}" icon="pi pi-check" />
</p:panel>
</h:form>
仅当用户从第一个下拉列表中选择国家/墨西哥/值3时,才需要从第二个下拉列表中选择Cancun/value 6选项这是否回答了您的问题?对不起,没有。在第二个下拉列表中,我们确保它是选中的/必须选择的项目。第二个
p:selectOneMenu
上根本没有必需的属性。尝试添加一个并使其成为“有条件的”,这是否回答了您的问题?对不起,它不起作用