Wednesday, March 28, 2012

PROJECT_STAGE in configuration file of JSF project

when we start a JSF project using netbeans, we get a skleton project containing two files at first.

a single facelet file called index.xhtml,
a web.xml configuration file


web.xml is the standard, optional(from version 3.0) configuration file needed for Java web.

If we observer we find that the NetBeans automatically sets the JSF project stage to Development, setting the project stage to development configures JSF to provide additional debugging help not present in other stages.

The following are the valid values for the javax.faces.PROJECT_STAGE context parameter for the faces servlet:

1.Development
2. Production
3.SystemTest
4.UnitTest

Development project stage adds additional debugging information to ease development. The Production project stage focuses on performance. The other two valid values for the project stage (SystemTest and UnitTest), allow us to implement our own custom behavior for these two phases.

The javax.faces.application.Application class has a getProjectStage() method that allows us to obtain the current project stage. Based on the value of this method, we can implement the code that will only be executed in the appropriate stage.

2 comments:

John Ortiz Ordoñez said...

Thanks for this.

Do you know how to change PROJECT_STAGE in Eclipse? Thanks in advance.

Tukhrejul Inam said...
This comment has been removed by a blog administrator.