JSF2
This is version . It is not the current version, and thus it cannot be edited.
Back to current version   Restore this version

Hier sind einige Informationen über JSF 2 gespeichert.

Google Richfaces vs Primefaces Trends#

RED = Primefaces, BLUE = Richfaces

Composite Tags#

AJAX Status#

Die Component zeit den AJAX-Status an.
<?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>

HTML Element Tag#

Der Tag rendert ein HTML-Element mit ClientId und übergibt alle Attribute und Childrens.
<?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="&lt;#{cc.attrs.element} id=&quot;#{cc.clientId}&quot;" escape="false"/>
			<c:forEach items="#{cc.attributes}" var="attribute">
				<h:outputText value=" #{attribute.key}=&quot;#{attribute.value}&quot;" 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="&gt;" escape="false"/>
			<cc:insertChildren/>
			<h:outputText value="&lt;/#{cc.attrs.element}&gt;" escape="false"/>
		</c:if>
	</cc:implementation>
</html>

Validierung prüfen#

FacesContext.getCurrentInstance().isValidationFailed();

Setup#

web.xml
	<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>