[My Setup: Java EE 6 application, with EJB3.1, CDI/Weld, JSF2 running on Glassfish 3.0.1]
I just read about the Faces ProjectStage on this page, which is a cool thing. So i configured it in my Web.xml, setting it to Development:
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
Now i want to access the ProjectStage from the JSF view (setting the visibility of specific UI components accordingly).
Therefore i already tried things like an outputtext with the value #{javax.application.projectStage}
, which seems to be null, and i also tried many other variants, with no success. I even don't manage to access the ProjectStage from within Java code (then i could expose it myself with a Bean).
How can i access the PROJECT_STAGE value inside my application?
Got it. From the view, it can be accessed like:
<h:outputText value="Stage:#{facesContext.application.projectStage}"/>
In the code, it can be accessed like:
FacesContext.getCurrentInstance().getApplication().getProjectStage().toString()
This is probably exposed via the initParam
implicit object. Failing that, check the ExternalContext.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With