为什么 f:param 值没有设置到资源包的消息中?

Why f:param value is not set into message from resource bundle?

我在我的网络应用程序中使用国际化,我想再次重用一些消息。
面孔-config.xml

<locale-config>
        <default-locale>en</default-locale>
        <supported-locale>uk</supported-locale>
    </locale-config>
    <resource-bundle>
        <base-name>international.message-labels</base-name>
        <var>msgLabel</var>
    </resource-bundle>

来自资源包的消息

inputLength=Length should be {0} or more

示例:

<p:inputText id="firstName" value="#{user.firstName}"
                placeholder="#{msgLabel.namePlaceHolder}" size="25" required="true"
                styleClass="logRegLabel" validatorMessage="#{msgLabel.inputLength}"
                requiredMessage="#{msgLabel.fieldCannotEmpty}">
                <f:param value="3" />
                <f:validateLength minimum="3" />
                <p:ajax event="blur" update="firstNameMsg" global="false" />
            </p:inputText>  

在我看到的所有示例中它都有效。但就我而言,我总是得到 Length should be {0} or more 而不是 Length should be 3 or more
我也试过这个validatorMessage="#{msgLabel['inputLength']}"
另外,我试图删除 p:inputText 的所有其他参数,但没有帮助

用于参数化捆绑消息的 <f:param> 仅在 <h:outputFormat> 内有效。

<h:outputFormat value="#{bundle.key}">
    <f:param value="value for {0}" />
    <f:param value="value for {1}" />
    <f:param value="value for {2}" />
</h:outputFormat>

JSF 不提供任何参数化任意属性值的工具。您最好的选择是创建一个 custom EL function 来完成如下工作:

<p:inputText ... validatorMessage="#{my:format1(msgLabel.inputLength, '3')}" />

如果您碰巧为此使用了 JSF 实用程序库 OmniFaces, then you can use its of:format1()

<p:inputText ... validatorMessage="#{of:format1(msgLabel.inputLength, '3')}" />

或其 <o:outputFormat> 支持捕获 EL 变量中的输出。

<o:outputFormat value="#{msgLabel.inputLength}" var="validatorMessage">
    <f:param value="3" />
</o:outputFormat>
<p:inputText ... validatorMessage="#{validatorMessage}" />