【问题标题】:Variable lookup parameter for resourceBundle?resourceBundle 的变量查找参数?
【发布时间】:2011-07-03 13:02:33
【问题描述】:

我目前正在使用 resourceBundle 变量来获取我的 JSF 代码中的文本值,例如像这样:

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

有什么方法可以将消息键放入变量中,并将其作为动态参数提供给资源包?我希望能够做这样的事情:

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

【问题讨论】:

    标签: java spring jsf spring-webflow resourcebundle


    【解决方案1】:

    只需使用方法 resolveKey(String key) 创建一个专用的 ManagedBean,从中调用 resourceBundle 查找并查看并使用该 bean。

    【讨论】:

      【解决方案2】:
      【解决方案3】:

      资源包采用动态参数。这是我项目中的 sn-p:

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

      【讨论】:

        猜你喜欢
        • 2018-08-14
        • 2020-03-15
        • 2013-02-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-09-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多