myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Myfaces Wiki] Update of "TrinidadSeamAjax4JsfFaceletDetail" by ThomasHamacher
Date Wed, 28 Feb 2007 13:38:48 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by ThomasHamacher:
http://wiki.apache.org/myfaces/TrinidadSeamAjax4JsfFaceletDetail

New page:
     
 
== Configure Trinidad for use with Seam, ajax4jsf  and Facelets ==

In a complex environment with a lot of different libraries to play together and therefor use
the best of all to fullfil your requirements, there are some things to keep in mind. This
is a short description on how I configured my application to make these components run together.

I´m referencing to the following environment:

    * Trinidad Nightly Build from Apache Incubator [http://people.apache.org/repo/m2-snapshot-repository/org/apache/myfaces/trinidad/]
    * JBoss Seam 1.1.6 [http://www.jboss.com/products/seam]
    * Ajax4jsf 1.0.6 [https://ajax4jsf.dev.java.net/]
    * Facelets 1.1.12 [https://facelets.dev.java.net/]
    * MyFaces 1.1.5 [http://myfaces.apache.org/]
    * JBoss Application Server 4.0.5 [http://labs.jboss.com/]

To make Trinidad play together with Ajax4jsf you also have to include the `a4j-trinidad.jar`.
The a4j-trinidad contains an alternative AjaxContext called TrinidadAjaxContext which is not
present in the main distribution, so you will need the extra library additional to the ajax4jsf-library.
You will find this at the ajax4jsf-website as well.


=== faces-config.xml ===
Let´s start with the `faces-config.xml`. It is very neccessary to remove all `view-handler`s
and instead set the `default-render-kit` to Trinidad. Then the faces-config.xml should look
something like this:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">

<faces-config>
    
    <!-- Phase listener needed for all Seam applications -->

    <lifecycle>
        <phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener>
    </lifecycle>
    
    <application>
        <default-render-kit-id>org.apache.myfaces.trinidad.core</default-render-kit-id>
    </application>

</faces-config>

=== web.xml ===
Let´s go over to the `web.xml`. First we have to define a special set of `listeners`. I don´t
think the order is that important in this case, but I started with the
SeamListener, which is declared as follows:

    <listener>
        <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
    </listener>
    

Afterward you have to define the listener for your JSF-Implementation. I used MyFaces and
therefor used this declaration:

    <listener>
        <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
    </listener>
    

But if you´re playing with SUN RI, declare it this way:

    <listener>
        <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>
    

For the most of the libraries you don´t have to set any special context-parameters, but when
it comes to the Trinidad `context-param`s the following declaration is 
necessary:

    <context-param>
        <param-name>org.apache.myfaces.trinidad.ALTERNATE_VIEW_HANDLER</param-name>
        
        <param-value>com.sun.facelets.FaceletViewHandler</param-value>
    </context-param>  
    

When it comes to the `filter-mapping` the order is very important. You have to define the
ajax4jsf-filter-mapping as the very first one, followed by the others.
This is the sequence I used in my web.xml:

    <!-- ************************ AJAX4JSF Filter **************************** -->
    
    <!-- If you have other filters declared in the web.xml, be sure that Ajax4jsf Filter
is declared before the others. -->
    
    <filter>
        <display-name>Ajax4jsf Filter</display-name>
        
        <filter-name>ajax4jsf</filter-name>
        
        <filter-class>org.ajax4jsf.Filter</filter-class>
        
        <init-param>
        
            <param-name>forceparser</param-name>
        
            <param-value>false</param-value>
        
        </init-param>
    
    </filter>
    
    <filter-mapping>
    
        <filter-name>ajax4jsf</filter-name>
    
        <servlet-name>Faces Servlet</servlet-name>        
    
        <dispatcher>REQUEST</dispatcher>
    
        <dispatcher>FORWARD</dispatcher>
    
        <dispatcher>INCLUDE</dispatcher>
    
    </filter-mapping>
    
    
    
    <!-- ************************ Trinidad Filter **************************** -->
    
    <filter>
        <filter-name>Trinidad</filter-name>
        
        <filter-class>org.apache.myfaces.trinidad.webapp.TrinidadFilter</filter-class>
    </filter>
    
    <filter-mapping>
        <filter-name>Trinidad</filter-name>
        
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    
    
    
    <!-- ************************ Seam Filter **************************** -->
    
    <filter>
        <filter-name>Seam Exception Filter</filter-name>
      
        <filter-class>org.jboss.seam.servlet.SeamExceptionFilter</filter-class>
    </filter>
    
    <filter-mapping>
        <filter-name>Seam Exception Filter</filter-name>
       
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <filter>
        <filter-name>Seam Redirect Filter</filter-name>
        
        <filter-class>org.jboss.seam.servlet.SeamRedirectFilter</filter-class>
    </filter>
    
    <filter-mapping>
        <filter-name>Seam Redirect Filter</filter-name>
       
        <url-pattern>*.seam</url-pattern>
    </filter-mapping>
    


This is all I did and it works quite nice and smoothly.  

Hope it helps someone to run these great libraries together, which makes development really
smooth and easy.

Have fun!

''Thomas Hamacher''  

Mime
View raw message