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
精彩评论