2013-05-03 91 views
0

我想顯示一個面板後,只是一個選擇項目,我想到,但它給了我一個錯誤。顯示一個面板後,只是一個選擇項目

代碼:

<h:outputText value="* produit" /> 
<h:selectOneMenu id="produit" value="#{clientMB.selectProduit}"> 
     <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="" value="lazyload()"/> 
</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> 

錯誤:

javax.servlet.ServletException: java.lang.String cannot be cast to javax.faces.model.SelectItem 

回答

0

解決方案

<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> 
相關問題