开发者

Variable lookup parameter for resourceBundle?

开发者 https://www.devze.com 2023-02-13 17:29 出处:网络
I\'m currently using the resourceBundle variable to get text values in my JSF code e.g. like this: <h:outputText value=\"#{resourceBundle.welcomeMessage}\" />

I'm currently using the resourceBundle variable to get text values in my JSF code e.g. like this:

<h:outputText value="#{resourceBundle.welcomeMessage}" />

Is there any way, to put the message key in a variable, and give it as a dynamic parameter to the 开发者_如何学Cresource bundle? I was hoping to be able to do something like this:

<c:set var="name" value="#{'welcomeMessage'}" />
<h:outputText value="#{resourceBundle.get(name)}" />


The resource bundle takes dynamic parameter. Here is snippet from my project:

    <f:loadBundle basename="#{siteName}" var="bundle"/>
        ....
               <h:dataTable value="#{summary.restrictionList}" var="restrictionList" cellspacing="0" cellpadding="0"> 
               ....

                            <h:outputFormat value="#{bundle['summary.label.blockcodemsg']}">
                                <f:param value="#{restrictionList['lastFourDigits']}"/>
                                <f:param value="#{bundle[restrictionList['optionDesc']]}"/>
                                <f:param value="#{bundle[restrictionList['optionResolutionDesc']]}"/>
                            </h:outputFormat>
     ....


Just create a dedicated ManagedBean with a method resolveKey(String key) from which call resourceBundle lookup and on view and use that bean.


Use h:outputFormat, see example: http://www.javabeat.net/tips/47-how-to-use-resource-bundle-in-jsf.html

0

精彩评论

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