【问题标题】:Displaying <h:inputText> and <h:selectOneMenu> as <f:param> of <h:outputFormat>将 <h:inputText> 和 <h:selectOneMenu> 显示为 <h:outputFormat> 的 <f:param>
【发布时间】:2013-09-17 11:39:14
【问题描述】:

我正在使用&lt;h:outputFormat&gt; 来格式化消息。

<h:outputFormat value="Sent {0} to {1} different people">
    ...
</h:outputFormat>

我想显示一个&lt;h:inputText&gt; 来代替参数{0} 和一个带有1-50 数字列表的&lt;h:selectOneMenu&gt; 来代替参数{1}

是否可以使用&lt;f:param&gt; 来做到这一点,或者有替代方法吗?

【问题讨论】:

    标签: jsf-2 param messageformat


    【解决方案1】:

    这对于标准 JSF 实现的 &lt;f:param&gt; 是不可能的。然而,这可以通过 JSF 实用程序库 OmniFaces&lt;o:param&gt; 实现,它增强了 &lt;f:param&gt;,支持提供真正的 JSF 代码作为格式参数。

    以下是使用&lt;o:param&gt; 解决问题的方法:

    <h:outputFormat value="Sent {0} to {1} different people" escape="false">
        <o:param>
            <h:inputText value="#{bean.input}" />
        </o:param>
        <o:param>
            <h:selectOneMenu value="#{bean.number}">
                <f:selectItems value="#{bean.numbers}" />
            </h:selectOneMenu>
        </o:param>
    </h:outputFormat>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-11
      • 1970-01-01
      • 2013-12-20
      • 2012-07-15
      • 1970-01-01
      • 1970-01-01
      • 2013-04-03
      • 2012-11-15
      相关资源
      最近更新 更多