JLLMNCHR
JLLMNCHR

Reputation: 1571

How to show a property loaded from properties file in JSF page

Is it possible, in a JSF page, to show a property loaded from a project.properties file (for example the database name)?

In project.properties:

cfg.bd.dbname=midatabase-name

In some jsf page some expression similar to this:

<h:outputText value="#{cfg.bd.dbname}" />

Thanks!

Upvotes: 4

Views: 1497

Answers (1)

BalusC
BalusC

Reputation: 1108782

You can (ab)use <f:loadBundle> for this.

<f:loadBundle basename="project" var="project" />
...
<h:outputText value="#{project['cfg.bd.dbname']} />

I said abuse, because the <f:loadBundle> is initially intented to load localized text bundles which allows for internationalization, but as it's under the covers using the same type of properties files, you could as good use it for any arbitrary properties file in the classpath.

Upvotes: 6

Related Questions