2017-08-18 14 views
0

xhtmlで複数のコンポーネントを表示するためにスイッチケースを使用しようとしていますが、動作しません。結果として、すべてのコンポーネントが表示されます。私はPrimeFaces 6.1、Eclipse Marsを使用していますPrimeFacesでスイッチケースを使用するとエラーが発生する

私はxhtmlで複数のコンポーネントを表示するためにSwitch Caseを使用しようとしていますが、動作しません。結果として、すべてのコンポーネントが表示されます。私はあなたの問題は、おそらくあなたがしていることである私の豆、あなたのコメントに基づいて

package vista; 

import javax.faces.bean.ManagedBean; 
import javax.faces.bean.RequestScoped; 
import javax.faces.bean.ViewScoped; 

public class Prueba { 

    @ManagedBean 
    @ViewScoped 
    public class SwitchController { 

     private String value=null; 

     public String getValue() { 
      return value; 
     } 

     public void setValue(final String value) { 
      this.value = value; 
     } 
    } 
} 

マイXHTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:p="http://primefaces.org/ui" 
    xmlns:c="http://java.sun.com/jstl/core" 
    xmlns:pe="http://primefaces.org/ui/extensions"> 
<h:head> 
    <title>prueba</title> 
</h:head> 
<body> 
    <h:form id="mainForm"> 
     <p:growl id="growl" showDetail="true" /> 

     <p:selectOneMenu id="caseSelection" value="#{switchController.value}"> 
      <f:selectItem itemLabel="Default case" itemValue="default" /> 
      <f:selectItem itemLabel="Case 1" itemValue="case1" /> 
      <f:selectItem itemLabel="null" itemValue="#{null}" /> 
      <f:selectItem itemLabel="Case 2" itemValue="case2" /> 

      <p:ajax update="swichWrapper" process="@this" /> 
     </p:selectOneMenu> 

     <p:separator /> 

     <p:outputPanel id="swichWrapper"> 
      <pe:switch id="switch" value="#{switchController.value}"> 
        <pe:defaultCase> 
          Case: Default 
        </pe:defaultCase> 

        <pe:case value="case1"> 
          Case: <p:commandButton id="case1button" actionListener="#{switchController.listener('case1')}" update=":mainForm:growl" 
              value="Call listener with 'case1'" /> 
        </pe:case> 

        <pe:case value="case2"> 
          Case: <p:commandButton id="case2button" actionListener="#{switchController.listener('case2')}" update=":mainForm:growl" 
              value="Call listener with 'case2'" /> 
        </pe:case> 

        <pe:case value="#{null}"> 
          Case: Null 
        </pe:case> 
      </pe:switch> 
     </p:outputPanel> 
    </h:form> 
</body> 
</html> 

結果 enter image description here

+0

どのバージョンのPrimeFaces Extensionsを使用していますか? –

+0

PrimeFaces 6.1 ... Switch Caseの別のライブラリをダウンロードする必要がありますか? –

答えて

0

をEclipseの火星

をPrimeFaces 6.1を使用していますPrimefaces拡張ライブラリがありません。あなたのpom.xmlに追加する必要があります

<dependency> 
    <groupId>org.primefaces.extensions</groupId> 
    <artifactId>primefaces-extensions</artifactId> 
    <version>6.1.0</version> 
</dependency> 
関連する問題