jsf - Error using Switch Case with PrimeFaces -
i'm trying use switch case show multiple components in xhtml, doesnt work. result shows components. i'm using primefaces 6.1 , eclipse mars
i'm trying use switch case show multiple components in xhtml, doesnt work. result shows components. i'm using primefaces 6.1 , eclipse mars
my beans
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; } } } my 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 'case1'" /> </pe:case> <pe:case value="case2"> case: <p:commandbutton id="case2button" actionlistener="#{switchcontroller.listener('case2')}" update=":mainform:growl" value="call listener 'case2'" /> </pe:case> <pe:case value="#{null}"> case: null </pe:case> </pe:switch> </p:outputpanel> </h:form> </body> </html> result enter image description here
based on comment problem missing primefaces extensions library. here should add pom.xml
<dependency> <groupid>org.primefaces.extensions</groupid> <artifactid>primefaces-extensions</artifactid> <version>6.1.0</version> </dependency>
Comments
Post a Comment