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:composite="http://java.sun.com/jsf/composite" > <composite:interface> <composite:attribute name="onbegin"/> <composite:attribute name="oncomplete"/> <composite:attribute name="onsuccess"/> <composite:attribute name="onerror"/> </composite:interface> <composite:implementation> <script type="text/javascript"> function updateBusyStatus(data) { <c:if test="#{cc.facets.begin != null}"> document.getElementById('#{cc.clientId}:begin').style.visibility = data.status == 'begin' ? 'visible' : 'hidden'; </c:if> <c:if test="#{cc.facets.complete != null}"> document.getElementById('#{cc.clientId}:complete').style.visibility = data.status == 'complete' ? 'visible' : 'hidden'; </c:if> <c:if test="#{cc.facets.success != null}"> document.getElementById('#{cc.clientId}:success').style.visibility = data.status == 'success' ? 'visible' : 'hidden'; </c:if> <c:if test="#{cc.facets.error != null}"> document.getElementById('#{cc.clientId}:error').style.visibility = data.status == 'error' ? 'visible' : 'hidden'; </c:if> } jsf.ajax.addOnEvent(updateBusyStatus); </script> <c:if test="#{cc.facets.begin != null}"> <div id="#{cc.clientId}:begin" style="visibility: hidden;"> <composite:renderFacet name="begin"/> </div> </c:if> <c:if test="#{cc.facets.complete != null}"> <div id="#{cc.clientId}:complete" style="visibility: hidden;"> <composite:renderFacet name="complete"/> </div> </c:if> <c:if test="#{cc.facets.success != null}"> <div id="#{cc.clientId}:success" style="visibility: hidden;"> <composite:renderFacet name="success"/> </div> </c:if> <c:if test="#{cc.facets.error != null}"> <div id="#{cc.clientId}:error" style="visibility: hidden;"> <composite:renderFacet name="error"/> </div> </c:if> </composite:implementation> </html>
Verwendung zum Beispiel wie folgt:
<test:ajaxStatus> <f:facet name="begin"> <h:graphicImage id="busyStatus" value="/images/wait30trans.gif"/> </f:facet> </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>