Wednesday, February 12, 2014


Java Server Faces project stage

http://www.java-tutorial.ch/java-server-faces/jsf-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.
1.<context-param>
2.<param-name>javax.faces.PROJECT_STAGE</param-name>
3.<param-value>Development</param-value>
4.</context-param>

Access project stage using expression language

You can access the project stage using unified expression language :
javax.faces.PROJECT_STAGE configuration parameter 
1.#{facesContext.application.projectStage}
2.#{initParam['javax.faces.PROJECT_STAGE']}

Project stage enum source

JSF  source of ProjectStage enumeration in JSF  2.0
jsf project_stage
01.public enum ProjectStage
02.{
03.Development,
04.Production,
05.SystemTest,
06.UnitTest;
07. 
08.public static final String PROJECT_STAGE_JNDI_NAME ="java:comp/env/jsf/ProjectStage";
09.public static final String PROJECT_STAGE_PARAM_NAME ="javax.faces.PROJECT_STAGE";
10.}

Writing conditional code with  javax.faces.PROJECT_STAGE configuration

Getting the project stage from the FacesContext application object instance.
conditional project stage example
1.FacesContext facesContext = FacesContext.getCurrentInstance();
2.Application application = facesContext.getApplication();
3.if (application.getProjectStage() == ProjectStage.Development) {
4.// Define development settings
5.}
Interrogating directly the FacesContext using the project stage enumeration
Spring java source
1.FacesContext facesContext = FacesContext.getCurrentInstance();
2.if (facesContext.isProjectStage(ProjectStage.Development)) {
3.// Define development settings
4.}

troubleshooting project stage issuesTroubleshooting 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.2Migrate 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: projectcurrentdevelopmentaccessapplicationimplementationexpressionstage,enumerationfacescontext

Comments  

4 comments:

for ict 99 said...

Great Article
JSF Online Training | JSF Training | JSF Training Courses | Java Training Institutes in Chennai | Java Training in Chennai | Java Course in Chennai | JSF Interview Questions

oakleyses said...

jordan pas cher, chanel handbags, nike outlet, michael kors pas cher, kate spade outlet, replica watches, longchamp pas cher, nike free, jordan shoes, christian louboutin shoes, nike free run, louis vuitton outlet, oakley sunglasses, ray ban sunglasses, polo ralph lauren, ugg boots, christian louboutin uk, air max, louis vuitton outlet, ugg boots, tiffany jewelry, polo ralph lauren outlet online, burberry pas cher, prada outlet, nike air max, gucci handbags, sac longchamp pas cher, ray ban sunglasses, louboutin pas cher, louis vuitton, uggs on sale, tiffany and co, oakley sunglasses, louis vuitton outlet, ray ban sunglasses, longchamp outlet, louis vuitton, longchamp outlet, replica watches, nike roshe, polo outlet, oakley sunglasses, cheap oakley sunglasses, oakley sunglasses wholesale, christian louboutin, christian louboutin outlet, tory burch outlet

oakleyses said...

lululemon canada, nike air max, burberry outlet, oakley pas cher, burberry handbags, coach outlet store online, kate spade, michael kors outlet, michael kors, nike air force, true religion jeans, true religion outlet, michael kors, polo lacoste, nike tn, new balance, abercrombie and fitch uk, michael kors outlet, uggs outlet, michael kors outlet, ralph lauren uk, michael kors outlet online, replica handbags, coach outlet, true religion outlet, coach purses, nike free uk, sac vanessa bruno, mulberry uk, michael kors outlet online, michael kors outlet online, michael kors outlet online, north face, uggs outlet, converse pas cher, hogan outlet, nike air max uk, hollister pas cher, sac hermes, nike roshe run uk, hollister uk, nike air max uk, true religion outlet, timberland pas cher, vans pas cher, ray ban pas cher, guess pas cher, ray ban uk

Unknown said...

www0626
canada goose outlet
longchamp bags
barbour jackets
san francisco 49ers jerseys
pandora charms
indianapolis colts jerseys
air jordan shoes
oakley sunglasses
pandora charms
givenchy handbags