Search code examples
jsf-2facelets

Define a property in Facelets page


I know that by using <f:loadBundle> I can load whole property file. But is there any tag in Facelets by which I can define a property in Facelets file and can use in Facelets page.

I know this can also be done by controller layer (like getSomeProperty()) but I don't want to do this. I am just looking for a tag that do this.

In other words we can do this in XML like this

<properties>
  <propertyName>propertyValue</propertyName>
<proprties>

So in Facelets how can I do this?


Solution

  • Just define a vanilla page-scoped variable using either JSTL. Using JSTL's <c:set/>:

    <c:set var="propertyName" value="propertyValue"/>
    

    You could then use #{propertyName} anywhere within your page.