How to add MyFaces support to a Sun JSF RI application
Introduction
MyFaces does have its own implementation of the JSF specification. But if you already have a working JSF web app based on the Sun JSF 1.1 reference implementation, you may want stay with it. The following describes the minimal steps necessary to add the MyFaces extensions to a Sun JSF 1.1 web app.
-
Versions these steps should work for:
-
Sun JSF 1.1.01
-
MyFaces 1.0.9 (success with version 1.1.1 has also been reported)
-
-
Notes:
-
The MyFaces version of Tiles Support will not work with this approach, but other components should work fine.
-
Steps
-
Put the myfaces-extensions.jar and the commons-fileupload-1.0.jar in your WEB-INF/lib directory (or in the classpath of your application server.)
-
Add the following lines to your web.xml file:
<!-- Extensions Filter --> <filter> <filter-name>extensionsFilter</filter-name> <filter-class> org.apache.myfaces.component.html.util.ExtensionsFilter </filter-class> <init-param> <description> Set the size limit for uploaded files. Format: 10 - 10 bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB </description> <param-name>uploadMaxFileSize</param-name> <param-value>100m</param-value> </init-param> <init-param> <description> Set the threshold size - files below this limit are stored in memory, files above this limit are stored on disk. Format: 10 - 10 bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB </description> <param-name>uploadThresholdSize</param-name> <param-value>100k</param-value> </init-param> <!-- <init-param> <param-name>uploadRepositoryPath</param-name> <param-value>/temp</param-value> <description>Set the path where the intermediary files will be stored. </description> </init-param> --> </filter> <filter-mapping> <filter-name>extensionsFilter</filter-name> <url-pattern>*.faces</url-pattern> </filter-mapping> <filter-mapping> <filter-name>extensionsFilter</filter-name> <url-pattern>/faces/*</url-pattern> </filter-mapping>
Note: you may need to change the url-pattern to match whatever pattern you are using (e.g. *.jsf instead of *.faces).
-
Add the following to your JSP page in order to use one of the MyFaces custom components:
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
That's it! You should now be able to add MyFaces components to your .jsp page.