java.lang.Object
jakarta.faces.component.UIComponent
jakarta.faces.component.UIComponentBase
jakarta.faces.component.UIOutput
jakarta.faces.component.html.HtmlOutputFormat
org.omnifaces.component.output.OutputFormat
- All Implemented Interfaces:
PartialStateHolder,StateHolder,TransientStateHolder,ValueHolder,ComponentSystemEventListener,FacesListener,SystemEventListenerHolder,EventListener
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
_.
- Since:
- 1.2
- Author:
- Bauke Scholtz
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe component type, which is "org.omnifaces.component.output.OutputFormat".Fields inherited from class jakarta.faces.component.html.HtmlOutputFormat
COMPONENT_FAMILYFields inherited from class jakarta.faces.component.UIComponent
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, FACETS_KEY, VIEW_LOCATION_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidencodeBegin(FacesContext context) If thevarattribute is set, start capturing the output.voidencodeEnd(FacesContext context) If thevarattribute is set, stop capturing the output and expose it in request scope by thevarattribute value as variable name.getVar()Returns the variable name which exposes the captured output into the request scope.voidsetValueExpression(String name, ValueExpression binding) An override which checks if this isn't been invoked onvarattribute.voidSets the variable name which exposes the captured output into the request scope.Methods inherited from class jakarta.faces.component.html.HtmlOutputFormat
getDir, getFamily, getLang, getRole, getStyle, getStyleClass, getTitle, isEscape, setDir, setEscape, setLang, setRole, setStyle, setStyleClass, setTitleMethods inherited from class jakarta.faces.component.UIOutput
clearInitialState, getConverter, getLocalValue, getValue, markInitialState, resetValue, restoreState, saveState, setConverter, setValueMethods inherited from class jakarta.faces.component.UIComponentBase
addClientBehavior, addFacesListener, broadcast, decode, encodeAll, encodeChildren, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getPassThroughAttributes, getRenderer, getRendererType, getRendersChildren, invokeOnComponent, isRendered, isTransient, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, visitTreeMethods inherited from class jakarta.faces.component.UIComponent
getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, subscribeToEvent, unsubscribeFromEvent
-
Field Details
-
COMPONENT_TYPE
The component type, which is "org.omnifaces.component.output.OutputFormat".- See Also:
-
-
Constructor Details
-
OutputFormat
public OutputFormat()
-
-
Method Details
-
setValueExpression
An override which checks if this isn't been invoked onvarattribute. Finally it delegates to the super method.- Overrides:
setValueExpressionin classHtmlOutputFormat- Throws:
IllegalArgumentException- When this value expression is been set onvarattribute.
-
encodeBegin
If thevarattribute is set, start capturing the output.- Overrides:
encodeBeginin classUIComponentBase- Throws:
IOException
-
encodeEnd
If thevarattribute is set, stop capturing the output and expose it in request scope by thevarattribute value as variable name.- Overrides:
encodeEndin classUIComponentBase- Throws:
IOException
-
getVar
Returns the variable name which exposes the captured output into the request scope.- Returns:
- The variable name which exposes the captured output into the request scope.
-
setVar
Sets the variable name which exposes the captured output into the request scope.- Parameters:
varName- The variable name which exposes the captured output into the request scope.
-