Hier sind einige Informationen über JSF 2 gespeichert.
<?xml version="1.0" encoding="UTF-8"?> <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:c="http://java.sun.com/jsp/jstl/core" xmlns:cc="http://java.sun.com/jsf/composite" > <cc:interface> <cc:attribute name="status" default="begin"/> </cc:interface> <cc:implementation> <script type="text/javascript"> jsf.ajax.addOnEvent(function(data) { document.getElementById('#{cc.clientId}:status').style.visibility = data.status == '#{cc.attrs.status}' ? 'visible' : 'hidden'; }); </script> <div id="#{cc.clientId}:status" style="visibility: hidden;"> <cc:insertChildren/> </div> </cc:implementation> </html>
Verwendung zum Beispiel wie folgt:
<test:ajaxStatus> <h:graphicImage value="/images/wait30trans.gif"/> </test:ajaxStatus>
<?xml version="1.0" encoding="UTF-8"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:cc="http://java.sun.com/jsf/composite" > <cc:interface name="test"> <cc:attribute name="element" required="true"/> <cc:attribute name="rendered"/> </cc:interface> <cc:implementation> <c:if test="#{!rendered or rendered}"> <h:outputText value="<#{cc.attrs.element} id="#{cc.clientId}"" escape="false"/> <c:forEach items="#{cc.attributes}" var="attribute"> <h:outputText value=" #{attribute.key}="#{attribute.value}"" escape="false" rendered="#{!attribute.key.startsWith('javax.faces') and !attribute.key.startsWith('com.sun') and attribute.key != 'element' and attribute.key != 'rendered'}"/> </c:forEach> <h:outputText value=">" escape="false"/> <cc:insertChildren/> <h:outputText value="</#{cc.attrs.element}>" escape="false"/> </c:if> </cc:implementation> </html>
FacesContext.getCurrentInstance().isValidationFailed(); #{facesContext.validationFailed}
<context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>server</param-value> </context-param> <context-param> <param-name>javax.faces.PROJECT_STAGE</param-name> <param-value>Development</param-value> </context-param> <context-param> <param-name>javax.faces.FACELETS_LIBRARIES</param-name> <param-value>/WEB-INF/test.taglib.xml</param-value> </context-param> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping>
<h:commandButton value="Test" action="#{test.action('param')}"/>
In der pom.xml die Libs referenzieren:
<dependency> <groupId>javax.el</groupId> <artifactId>el-api</artifactId> <version>2.2</version> </dependency> <dependency> <groupId>org.glassfish.web</groupId> <artifactId>el-impl</artifactId> <version>2.2</version> </dependency> <repository> <id>maven.java.net</id> <name>Java.net Maven2 Repository</name> <url>http://download.java.net/maven/2</url> </repository>
Und in der web.xml die Factory festlegen:
<context-param> <param-name>com.sun.faces.expressionFactory</param-name> <param-value>com.sun.el.ExpressionFactoryImpl</param-value> </context-param>
In Google Application Engine klappt das nicht, dort kann nur JBoss EL verwendet werden.