开发者

JSF - how to dynamically display values from messages.properties

I have a DataModel which has plan names and some other attributes.

I have different plans - gold , silver etc. But I dont want to d开发者_开发知识库isplay Gold or Silver as it is. Based on the locale, I want to display it from the messages.properties

Here is my code snippet:

           <h:dataTable value="#{newMemberController.membershipModel}"   
            var="plans" styleClass="gird_header_value">
            <h:column><h:outputText value="#{plans.name}" /></h:column>

So instead of plans.name value I want something like #{msgs.#{plans.name}} but this gives me a compilation error.

Does anyone know what is the correct syntax for this?


You can use the brace notation to access Map values with a dynamic key: #{map[key]}.

Thus, the following example should do:

<h:outputText value="#{msgs[plans.name]}" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜