Set project stage for JavaServer Faces with JNDI c

2019-05-16 12:41发布

I'm trying to set the project stage for JavaServer Faces in a GlassFish application server v3 with a JNDI property.

I set the stage property to Development stage, but my application received always the Production stage.

enter image description here

I use GlassFish Server Open Source Edition 3.1 (build 43) on a windows system.

For rendering the project stage in the JSF page I use this:

<h:outputText value="Stage:#{facesContext.application.projectStage}"/>

Is anything else necessary to use the project stage in an application? The application has no web.xml file.

2条回答
Rolldiameter
2楼-- · 2019-05-16 13:12

Everything is correct, but instead of stage=Development, use value = Development, i.e. replace stage with value in the property name field.

查看更多
虎瘦雄心在
3楼-- · 2019-05-16 13:33

You need this in your web.xml. It works with 'stage' then.

<resource-ref>
        <res-ref-name>jsf/ProjectStage</res-ref-name>
        <res-type>java.lang.String</res-type>
        <mapped-name>javax.faces.PROJECT_STAGE</mapped-name>
</resource-ref>

This maps the global JNDI property of GF to the reference lookup in JSF.

查看更多
登录 后发表回答