gpt4 book ai didi

java - 如何缩短资源包调用?复合组件?

转载 作者:行者123 更新时间:2023-11-30 09:40:24 25 4
gpt4 key购买 nike

我对内置的 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.* 而不是获取值内容。

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

最佳答案

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

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

关于java - 如何缩短资源包调用?复合组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9440191/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com