JSF呼叫消息束:EL中的EL [英] JSF call message bundle : EL in EL

查看:90
本文介绍了JSF呼叫消息束:EL中的EL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在JSF2中工作,并且显示了资源束以显示来自属性文件的消息.

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

配置似乎很棒(如果我呼叫#{msg.risk}显示"toto")

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

messages.properties

messages.properties

...
COMPANYGROWTH=E249
RISK=TOTO

我想做这种事情:

查看

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

将EL放入类似#{msg.#{key}}的EL中,其中key将是数据表中已声明的行值.有办法吗?

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 ?

谢谢

推荐答案

为此,您应该使用大括号符号#{bean[property]}.

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

因此,

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

请注意,嵌套EL表达式始终是无效语法.您应该将#{...}看作是一个很大的评估空间,变量之间相互影响.您不应将#{...}视为单个变量.

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.

这篇关于JSF呼叫消息束:EL中的EL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆