2013-05-03 48 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>