T0oto0
T0oto0

Reputation: 33

JSF call message bundle : EL in EL

I am working in JSF2 and I have displayed a resource bundle to display messages from property files.

The configuration seems to be great (if I call #{msg.risk} "toto" is displayed)

messages.properties

...
COMPANYGROWTH=E249
RISK=TOTO

I would like to do this kind of thing :

View

<f:loadBundle basename="toto" var="msg"/>
...
<p:column>
    <h:outputText value="#{msg.#{key}}" />
</p:column>

Putting an EL in an EL like #{msg.#{key}} where key would be a declared row value in a datatable. Is there a way to do it ?

Thanks

Upvotes: 1

Views: 1055

Answers (1)

BalusC
BalusC

Reputation: 1109272

For that you should be using the brace notation #{bean[property]}.

Thus, so:

<h:outputText value="#{msg[key]}" />

Note that nesting EL expressions is always invalid syntax. You should see #{...} as one big evaluation space where variables interact with each other. You should not see #{...} as a single variable.

See also:

Upvotes: 2

Related Questions