【问题标题】:How can I shorten resource bundle calls? Composite component?如何缩短资源包调用?复合组件?
【发布时间】:2012-03-15 11:03:02
【问题描述】:

我对内置 JSF 资源包的可能性并不满意,例如:

<h:outputFormat value="#{messages['form.label.create']}">

因此我尝试编写自己的复合组件来缩短这些内容:

<composite:interface>

    <composite:attribute name="value" />
    <composite:attribute name="p1" />

</composite:interface>


<composite:implementation>
    <h:outputFormat value="#{messages['cc.attrs.value']}"> //text.properties
        <f:param value="#{cc.attrs.p1}" />
    </h:outputFormat>
</composite:implementation>

用法:

<cc:messages value="label.name" p1="#{test}" />

但表达式 messages['cc.attrs.value'] 在资源包中查找 cc.attrs.* 而不是获取值内容。

我可以忘记我的方法吗?有没有人知道如何做类似的事情?

【问题讨论】:

    标签: java jsf resourcebundle


    【解决方案1】:

    尝试改写messages[cc.attrs.value]

    JSF 将 'cc.attrs.value' 解释为字符串值而不是变量名。

    【讨论】:

      猜你喜欢
      • 2015-08-31
      • 2018-10-04
      • 2015-09-16
      • 2013-10-16
      • 1970-01-01
      • 1970-01-01
      • 2011-09-18
      • 2011-12-07
      • 2011-10-10
      相关资源
      最近更新 更多