This page shows you how to switch from MyFaces to Sun's Reference Implementation (RI) for JSF.
- In your pom.xml, exclude the MyFaces dependencies from your warpath dependency:
<dependency>
<groupId>org.appfuse</groupId>
<artifactId>appfuse-${web.framework}</artifactId>
<version>${appfuse.version}</version>
<type>warpath</type>
<exclusions>
...
<exclusion>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
- Add Sun's RI dependencies:
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>1.2_04</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>1.2_04</version>
</dependency>
- Comment out (or remove) the StartupServletContextListener from your web.xml:
<!--<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>-->
- Modify sitemesh.xml to add a new parser for application/xhtml+xml:
<parser content-type="application/xhtml+xml" class="com.opensymphony.module.sitemesh.parser.FastPageParser"/>
- For some reason, the eval() JavaScript call that's used in global.js's highlightTableRows() function doesn't work. Comment it out on line 270:
if (call.indexOf("return ") == 0) {
call = call.substring(7);
}
- There are a few pages in AppFuse that use JavaScript to invoke a JSF page. JSF 1.2's @PostConstruct annotation should eliminate the need for these pages, but I've (so far) been unable to get @PostConstruct to work on Tomcat or Jetty. I've been able to get it to work on GlassFish. You need to change the JavaScript on the following pages from MyFace's syntax to the RI's.
- editProfile.xhtml:
<script type="text/javascript">
jsfcljs(document.forms['userProfile'],'userProfile:edit,userProfile:edit','');
</script>
- passwordHint.xhtml:
<script type="text/javascript">
jsfcljs(document.forms['passwordForm'],'passwordForm:execute,passwordForm:execute,username,mraible','')
</script>
- reload.xhtml:
<script type="text/javascript">
jsfcljs(document.forms['reloadForm'],'reloadForm:execute,reloadForm:execute,referrer,','');
</script>
After making all of these changes - you should be able to run mvn clean install and all the tests should pass.
Running Sun's RI on a Servlet 2.4 Container
MyFaces 1.2.0 requires JSP 1.2 to run. This means that you have to use a Servlet 2.5 container - like Tomcat 6 or Jetty 6.
Sun's RI can be run on a Servlet 2.4 container. To modify your application so it can deploy on Tomcat 5.x, add the following dependencies to your pom.xml:
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.sun.el</groupId>
<artifactId>el-ri</artifactId>
<version>1.2</version>
</dependency>
To prove this works, you can configure the Tomcat Maven Plugin in your pom.xml and start it using mvn tomcat:run-war. Below is the configuration needed for the plugin.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<configuration>
<path>/</path>
</configuration>
</plugin>
This plugin uses Tomcat 5.5.15.
 | Tomcat 5 vs. 6 If you package the el-api and el-ri JARs in your project (by including the dependencies in your pom.xml), your application will fail to deploy on Tomcat 6 and Jetty 6. If you remove these dependencies, it should deploy without any issues. |