Ajax4JSF is a library that easily adds ajax functionality to existing jsf components. As oppose to Icefaces which is a set of jsf components that already have built in ajax functionalities, Ajax4JSF offers a much flexible way to add ajax functionalities to jsf components. It offers refreshing of display without the need to refresh the entire form. On the downside, Ajax4JSF is harder to use for very complex jsf components.

Using Ajax4JSF in seam 2.0 is easy. Just remove the line in your faces-config.xml:

<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
and add the following code on your web.xml just aboe the seam listener definition:
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>com.sun.facelets.FaceletViewHandler</param-value>
</context-param>
You will also need to define the following on you xml schema:
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax
The following code is an example of a simple clock functionality that updates its time by polling / reRendering the component. I didnt use a backing bean on this example:

<h:outputText id="currentDateTime" value="#{currentDatetime}" styleClass="dateTime">
<s:convertDateTime pattern="MMMM dd, yyyy - hh:mm:ss a"/>
</h:outputText>

<h:form>
<a4j:poll interval="1000" reRender="currentDateTime"></a4j:poll>
</h:form>

0 comments:

Newer Post Older Post Home

Blogger Template by Blogcrowds