Jsf 2 仅在选定项后显示面板

Jsf 2 仅在选定项后显示面板,jsf-2,primefaces,Jsf 2,Primefaces,我想在一个选中的项目后显示一个面板,我想到了这一点,但它给了我一个错误 代码: 解决方案 <h:outputText value="* produit" /> <h:selectOneMenu id="produit" value="#{clientMB.selectProduit}" onchange="lazyload()"> <p:ajax update="client" listener="#{clientMB.getClientsProduit}"

我想在一个选中的项目后显示一个面板,我想到了这一点,但它给了我一个错误

代码:

解决方案

<h:outputText value="* produit" />
<h:selectOneMenu   id="produit" value="#{clientMB.selectProduit}"  onchange="lazyload()">
<p:ajax update="client" listener="#{clientMB.getClientsProduit}" />
<f:selectItem itemLabel="Select One" itemValue="" /> 
<f:selectItems value="#{produitMB.produits}" noSelectionValue="" var="prod" itemValue="#{prod.refProd}" itemLabel="#{prod.libProd}" />
<f:selectItem itemLabel="Autre" itemValue="" /> 
</h:selectOneMenu>
<p:outputPanel id="lazypanel" layout="block">  
<h:outputText value="This part of page is lazily loaded on demand using a RemoteCommand" rendered="#{requestScope.shouldRender}"/>  
</p:outputPanel> 
<p:remoteCommand name="lazyload" update="lazypanel">  
<f:setPropertyActionListener value="#{true}" target="#{requestScope.shouldRender}" />  
</p:remoteCommand>  

javax.servlet.ServletException: java.lang.String cannot be cast to javax.faces.model.SelectItem
<h:outputText value="* produit" />
<h:selectOneMenu   id="produit" value="#{clientMB.selectProduit}"  onchange="lazyload()">
<p:ajax update="client" listener="#{clientMB.getClientsProduit}" />
<f:selectItem itemLabel="Select One" itemValue="" /> 
<f:selectItems value="#{produitMB.produits}" noSelectionValue="" var="prod" itemValue="#{prod.refProd}" itemLabel="#{prod.libProd}" />
<f:selectItem itemLabel="Autre" itemValue="" /> 
</h:selectOneMenu>
<p:outputPanel id="lazypanel" layout="block">  
<h:outputText value="This part of page is lazily loaded on demand using a RemoteCommand" rendered="#{requestScope.shouldRender}"/>  
</p:outputPanel> 
<p:remoteCommand name="lazyload" update="lazypanel">  
<f:setPropertyActionListener value="#{true}" target="#{requestScope.shouldRender}" />  
</p:remoteCommand>