-
Available since OmniFaces 1.2
The <o:outputFormat>
is a component that extends the standard <h:outputFormat>
with support for capturing the output and exposing it into the request scope by the variable name as specified by the var
attribute.
You can use it the same way as <h:outputFormat>
, you only need to change h:
into o:
to get the extra support for var
attribute. Here's are some usage examples:
<o:outputFormat value="#{i18n['link.title']}" var="_link_title">
<f:param value="#{bean.foo}" />
<f:param value="#{bean.bar}" />
</o:outputFormat>
<h:commandLink value="#{i18n['link.value']}" title="#{_link_title}" />
<o:outputFormat value="#{bean.number}" var="_percentage">
<f:convertNumber type="percent" />
</o:outputFormat>
<div title="Percentage: #{_percentage}" />
Make sure that the var
attribute value doesn't conflict with any of existing variable names in the current EL scope, such as managed bean names. It would be a good naming convention to start their names with _
.
Demo
Check the tooltip.
Demo source code
<o:outputFormat value="some {0} i18n {1} bundle {2} text" var="_title">
<f:param value="one" />
<f:param value="two" />
<f:param value="three" />
</o:outputFormat>
<p title="#{_title}">Check the tooltip.</p>
Documentation & Sources