Monday Sep 02

JSF Project Stage

PDF Print E-mail
Friday, 27 May 2011 13:14
AddThis Social Bookmark Button

Java Server faces Project Stage configuration
Java Server Faces project stage

JSF 2.0 has introduced a new feature called project stage . Project stage is a new configuration option that allows the application developer/deployer to specify a hint to the JSF implementation regarding the role of the current deployment. Valid values include:

  • Development
  • Production
  • SystemTest
  • UnitTest

This hint allows the JSF implementation to optimize its behavior for the current stage. For example, the JSF implementation might provide more verbose development-time diagnostics than would be practical for a production environment.

Doing this enables better error messages, including in the client side JavaScript, at the cost of some performance.

To enabled Project Stage in your web application put the following snippet in your web.xml file.


Access project stage using expression language

You can access the project stage using unified expression language :
javax.faces.PROJECT_STAGE configuration parameter


Project stage enum source

JSF source of ProjectStage enumeration in JSF 2.0

jsf project_stage

public enum ProjectStage
    public static final String PROJECT_STAGE_JNDI_NAME = "java:comp/env/jsf/ProjectStage";
    public static final String PROJECT_STAGE_PARAM_NAME = "javax.faces.PROJECT_STAGE";

Writing conditional code with  javax.faces.PROJECT_STAGE configuration

Getting the project stage from the FacesContext application object instance.

conditional project stage example

FacesContext facesContext = FacesContext.getCurrentInstance();
Application application = facesContext.getApplication();
if (application.getProjectStage() == ProjectStage.Development) {
    // Define development settings

Interrogating directly the FacesContext using the project stage enumeration

Spring java source

FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext.isProjectStage(ProjectStage.Development)) {
    // Define development settings

troubleshooting project stage issues Troubleshooting project stage issues

Impossible to change project stage (development) Impossible to change project stage away from development

Fix problem impossible to change project stage by migrating to JSF 2.1.2 Migrate to JSF 2.1.2 The bug JAVASERVERFACES-2079 has been fixed in JSF 2.1.2

If you have any remark or questions feel free to put a comment.If you enjoyed this tutorial and want to promote it don't hesitate to click on

Tags: project , current , development , access , application , implementation , expression , stage , enumeration , facescontext

Add comment

Security code

Java Tutorial on Facebook