2011-02-24 52 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。