JSF call message bundle : EL in EL

泄露秘密 提交于 2020-01-11 07:18:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!