我需要在我的网页上使用两个primefaces selectonmenus。
我的第二个选择菜单在它具有静态数据时工作,所有数据都可以在按下按钮后单击按钮查看
但它不适用于动态数据数据在使用 ajax 数据加载到此 selectonmenu 从第一个 selectonmenu 中选择一个值后加载到此 selectonmenu 但在从中选择一个值后它始终显示空值
这是第 1 点的代码
<p:tab id="create_Subnet_T" title="Create subnet">
<h:form id="create_Subnet">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText value="Area:"/>
<p:selectOneMenu id="AreaDDL" value="#{a_Subnet.selectedArea}" required="true">
<f:selectItem itemLabel="Select area" itemValue="" />
<f:selectItems value="#{a_Subnet.areaList}" />
</p:selectOneMenu>
<h:outputText id="create_Subnet_OT" value="IP Address :" />
<p:selectOneMenu id="resourceDDL" value="#{a_Subnet.selectedResource}" required="true">
<f:selectItem itemLabel="Select resource" itemValue="A" />
<f:selectItem itemLabel="Select resource" itemValue="B" />
<f:selectItem itemLabel="Select resource" itemValue="C" />
</p:selectOneMenu>
<h:outputText id="netmask_OT" value="netmask :" />
<p:inputText id="netmask_IT" required="true" value="#{a_Subnet.netmask}"/>
<h:outputText id="description_OT" value="Description :" />
<p:inputTextarea id="description_ITA" required="true" value="#{a_Subnet.description}"/>
<p:commandButton id="create_Subnet_Btn" value="Create" action="#{a_Subnet.test}" />
</h:panelGrid>
</h:form>
这是不起作用的代码(对于第 2 点):
<p:tab id="create_Subnet_T" title="Create subnet">
<h:form id="create_Subnet">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText value="Area:"/>
<p:selectOneMenu id="AreaDDL" value="#{a_Subnet.selectedArea}" required="true">
<f:selectItem itemLabel="Select area" itemValue="" />
<f:selectItems value="#{a_Subnet.areaList}" />
<p:ajax event="change" update=":Subnet_TV:create_Subnet:resourceDDL"
listener="#{a_Subnet.setResourceToDropDownList(a_Subnet.selectedArea)}"/>
</p:selectOneMenu>
<h:outputText id="create_Subnet_OT" value="IP Address :" />
<p:selectOneMenu id="resourceDDL" value="#{a_Subnet.selectedResource}" required="true">
<f:selectItem itemLabel="Select resource" itemValue="A" />
<f:selectItems value="#{a_Subnet.resourceList}" />
</p:selectOneMenu>
<h:outputText id="netmask_OT" value="netmask :" />
<p:inputText id="netmask_IT" required="true" value="#{a_Subnet.netmask}"/>
<h:outputText id="description_OT" value="Description :" />
<p:inputTextarea id="description_ITA" required="true" value="#{a_Subnet.description}"/>
<p:commandButton id="create_Subnet_Btn" value="Create" action="#{a_Subnet.test}" />
</h:panelGrid>
</h:form>
</p:tab>
这是 ajax 中用于检查输出的方法:
public void test(){
System.out.println("hjhjjh");
System.err.println( "Area = "+selectedArea);
System.err.println("Resource = "+selectedResource);
System.err.println("SNetmask = "+netmask);
System.err.println("Description = "+description);
}