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
4

1 回答 1

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>  
于 2013-05-04T16:41:28.040 回答