tags:

views:

34

answers:

2

[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?

+1  A: 

This is probably exposed via the initParam implicit object. Failing that, check the ExternalContext.

McDowell
+1  A: 

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()
ifischer