struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mraible <m...@raibledesigns.com>
Subject Re: Can I integrate Struts 2 + JSF and Facelets?
Date Thu, 26 Jul 2007 17:35:42 GMT

Thanks for your help. I was able to get it working with Sun's RI + Facelets.
I'm confident I could get it working with MyFaces 1.2 as well - but since
they require a JSP 2.1 container (Sun's RI doesn't), I'll stick with the RI.

Here's the two ways I discovered:

1. Create a faces-config.xml file with the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
              version="1.2">

    <application>
        <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
    </application>
</faces-config>

2. Integrate Ajax4JSF (no faces-config.xml required) and add the following
to your web.xml:

    <context-param>
        <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
        <param-value>com.sun.facelets.FaceletViewHandler</param-value>
    </context-param>

There does seem to be a bug with this integration however. The content-type
returned from a Facelets page by default is:

Content-Type: application/xhtml+xml; charset=UTF-8

Since I'm using SiteMesh, my Facelets pages don't get decorated by default.
The workaround seems to be adding the following at the top of my pages:

<f:view contentType="text/html">

This doesn't happen when using JSP for the view. It also doesn't happen when
I use JSF standalone.

Matt

Laurie Harper wrote:
> 
> mraible wrote:
>> I'm trying to integrate JSF into a Struts 2 prototype. AFAICT, I need to
>> add
>> the struts-jsf-plugin to my pom.xml and add FacesServlet to my web.xml.
>> Are
>> there any other steps needed?
>> 
>> I'm using Sun's RI since it run's on Tomcat 5.x with JSP 2.0. How do I
>> tell
>> JSF to use Facelets w/o a faces-config.xml file? Does the plugin only
>> work
>> with MyFaces + JSP?
> 
> The JSF plugin should work with either MyFaces or the RI, and Facelets 
> should work too. I don't think you can get Facelets configured without 
> making the usual additions to web.xml and faces-config.xml, though, so 
> you'll need to do that as normal.
> 
> L.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Can-I-integrate-Struts-2-%2B-JSF-and-Facelets--tf4138220.html#a11815395
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message