JSF Desktop is a library to support JSF 2 (2.0, 2.1) with some basic features to extend JSF.
Overview#
The main features of the JSF-Ext (formerly JSF Desktop) are:- Events: Event sources and registration. Java beans and components can produce events, other beans and components can consume them. This includes rendering and updating components, even using AJAX requests.
- Messages: Clean message handling. Exceptions are converted to faces messages, using normal or AJAX requests. An event is raised, thus you can update your message components.
- Dynamic Includes: Clean component tree and small network traffic. Facelets can dynamically are loaded from XHTML sources when needed through AJAX requests. No more overloaded component trees, no waiting for loading all the megabytes to your browser. You can include as much popups, tabs and other elements in your page without slowing it down. Everything is just loaded when needed. And much better, its also can be unloaded when finished. Both DOM and component tree stays clean.
- Custom Scopes: Use custom scopes within your loaded facelets, they are cleaned up when finished. No more manual clearing of data from popups. Nice memory footprint and save data.
- Integration: JSF-Ext works perfectly together with Richfaces, Primefaces and other component libraries.
Configuration#
In the pom.xml use:<dependency> <groupId>com.intersult</groupId> <artifactId>jsf-desktop</artifactId> <version>1.1-SNAPSHOT</version> </dependency> <repository> <id>intersult-repository</id> <name>Intersult Repository</name> <url>http://repository.intersult.com/repository</url> </repository>
In the web.xml use:
<context-param> <param-name>javax.faces.FACELETS_RESOURCE_RESOLVER</param-name> <param-value>com.intersult.jsf_desktop.util.ClassPathResourceResolver</param-value> </context-param>
Access via http://localhost/faces/resource/<test.xhtml>
Insert-Tag#
The Insert-Tag can insert UIComponent objects into the component tree. This is usefull when creating XHTML-Components with namespace http://java.sun.com/jsf/composite/...Example#
Imagin a component which evenly distributes Command-Buttons in a form. You'de like to create a component (luckily this is already included in JSF Desktop). The component should wrap each contained component in a SPAN-Tag with some padding.Solution: You iterate through the children and write a span for each child. Into the span you insert the child itself. With normal JSF-Tags this is not possible, you need <i:insert>
<?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:ui="http://java.sun.com/jsf/facelets" xmlns:cc="http://java.sun.com/jsf/composite" xmlns:p="http://primefaces.prime.com.tr/ui" xmlns:i="http://intersult.com/taglib" xmlns:dt="http://java.sun.com/jsf/composite/desktop" > <cc:interface> <cc:attribute name="align"/> </cc:interface> <cc:implementation> <div style="margin-top: 10px; text-align: #{empty cc.attrs.align ? 'center' : cc.attrs.align};"> <ui:repeat value="#{cc.children}" var="child"> <span style="margin-right: 5px;"> <i:insert component="#{child}"/> </span> </ui:repeat> </div> </cc:implementation> </html>