Page 1 of 1

JSF 2 - How can I get a context-param value from web.xml usi

PostPosted: Tue Mar 19, 2013 4:10 pm
by haretu
Code: Select all
<web-app>
    <context-param>
        <param-name>myconstantkey</param-name>
        <param-value>some string value</param-value>
    </context-param>
</web-app>


Getting these values from inside a backing bean is easy enough:

Code: Select all
FacesContext ctx = FacesContext.getCurrentInstance();
String myConstantValue =
    ctx.getExternalContext().getInitParameter("myconstantkey");


in jsf front page
Code: Select all
<h:outputText value="#{initParam['myconstantkey']}" />