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
どのバージョンのPrimeFaces Extensionsを使用していますか? –
PrimeFaces 6.1 ... Switch Caseの別のライブラリをダウンロードする必要がありますか? –