动态构建资源包的“密钥”?

时间:2012-03-26 20:58:48

标签: java jsf

我可以在jsf servlet中“构建”我的资源包密钥吗?

这样的事情:

<cc:myComponent type="person" />
<cc:myComponent type="payment" />

myComponent的:

<composite:attribute name="type" />

<h:outputText value="message.xx.type" />

束:

message.xx.person = i'm a person
message.xx.payment = i'm a payment

可能以某种方式?

1 个答案:

答案 0 :(得分:0)

如果您使用的是EL 2.2,可以使用组件实现部分的以下代码完成:

<h:outputText value="#{'message.xx.'.concat(cc.attrs.type)]}" />

问题在于如何在EL中连接字符串,还有另外一个问题: Concatenate strings in JSF/JSP EL and Javascript

如果您没有使用EL 2.2,那么您将在我刚刚链接的相同问题上找到答案。

相关问题