Search code examples
jsf-2parammessageformat

Displaying <h:inputText> and <h:selectOneMenu> as <f:param> of <h:outputFormat>


I'm using <h:outputFormat> to format a message.

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

I would like to display a <h:inputText> in place of parameter {0} and a <h:selectOneMenu> with list of numbers from 1-50 in place of parameter {1}.

Is it possible to do so using <f:param>, or is there an alternative?


Solution

  • This is not possible with the <f:param> of the standard JSF implementation. This is however possible with the <o:param> of JSF utility library OmniFaces which has enhanced the <f:param> with the support of supplying real JSF code as format parameter.

    Here's how you can solve it using <o:param>:

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