Download for JSF2 .x
You can download the latest version from maven central repository: http://search.maven.org/.
- GroupId: com.ocpsoft
- ArtifactId: prettyfaces-jsf2
Configure PrettyFaces in web.xml
<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
PrettyFaces Development Mode
PrettyFaces is capable of reloading its configuration on a regular basis. As the configuration reloading may be a time consuming process for large applications, PrettyFaces reloads its configuration only if the application is executed in development mode.
To enable the development mode, add the following context parameter to your
web.xml
:<context-param>
<param-name>com.ocpsoft.pretty.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
If your are using the JSF 2.0 version of PrettyFaces, you typically won't have to explicitly enable the development mode. In this case the development mode is automatically enabled for all project stages except for
Production
.Annotation based configuration
Recently PrettyFaces added support to configure URL mappings via annotations. This feature is primarily intended for people who don't want to maintain a separate XML configuration file for the mappings and instead prefer to declare them directly on the affected classes.
Basic setup
You can specify the packages to scan for annotations by adding a comma-separated list of packages to your
web.xml
:<context-param> <param-name>com.ocpsoft.pretty.BASE_PACKAGES</param-name> <param-value>com.example.myapp,com.ocpsoft</param-value> </context-param>PrettyFaces will scan these packages recursively. So typically you will only have to add the top-level package of your web application here.
If you don't want to use PrettyFaces annotations at all, you can completely disable the annotation scanning by setting the package configuration parameter to
none
.<context-param> <param-name>com.ocpsoft.pretty.BASE_PACKAGES</param-name> <param-value>none</param-value> </context-param>In the default configuration PrettyFaces will only scan for annotations in the
/WEB-INF/classes
directory of your web application. If you want the JAR files in /WEB-INF/lib
to be scanned as well, add the following entry to your web.xml
:<context-param> <param-name>com.ocpsoft.pretty.SCAN_LIB_DIRECTORY</param-name> <param-value>true</param-value> </context-param>