luni, 9 martie 2015

[OmniFaces utilities (2.0)] Check whether we're in development stage


[OmniFaces utilities] The isDevelopment() method returns whether we're in development stage. This will be the case when the javax.faces.PROJECT_STAGE context parameter in web.xml is set to Development.

Method:
Usage:

import org.omnifaces.util.Faces;
...
boolean isdev = Faces.isDevelopment();

or,

import static org.omnifaces.util.Faces.isDevelopment;
...
boolean isdev = isDevelopment();


Note The project stage affects how JSF works. Basically, the development stage provide verbose error/info/warning messages, including in the client-side JavaScript, while production stage suppress several errors/info/warning messages and provide a slightly better performance. Most probably, you will set the project stage in web.xml via javax.faces.PROJECT_STAGE context parameter (OmniFaces test the value of this context parameter):

<context-param>
 <param-name>javax.faces.PROJECT_STAGE</param-name>
 <param-value>Development</param-value>
</context-param>

<context-param>
 <param-name>javax.faces.PROJECT_STAGE</param-name>
 <param-value>Production</param-value>
</context-param>

Beside Development and Production, the project stage can be undergoing unit testing stage (UnitTest) and system testing stage (SystemTest).

For more details, please check StackOverflow.

Niciun comentariu:

Trimiteți un comentariu