问题
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
回答1:
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:
- Our EL wiki page
来源:https://stackoverflow.com/questions/17235206/jsf-call-message-bundle-el-in-el