2011-02-24 57 views
2

我目前使用resourceBundle变量在我的JSF代码中获取文本值,例如像这样:resourceBundle的变量查找参数?

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

有什么办法,把消息中的关键变量,并给它作为一个动态参数的资源包?我希望能够做这样的事情:

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

'ResourceBundle.getString'? – 2011-02-24 12:31:59

回答

1

资源包需要动态参数。这里是我的项目的片段:

<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> 
    .... 
1

只需创建一个专用ManagedBean与方法resolveKey(String key)从中调用资源包查找并查看和使用该bean。