public class OutputFormat extends HtmlOutputFormat
HtmlOutputFormat
and provides 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
_
.
Modifier and Type | Field and Description |
---|---|
static String |
COMPONENT_TYPE
The standard component type.
|
COMPONENT_FAMILY
BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, VIEW_LOCATION_KEY
Constructor and Description |
---|
OutputFormat() |
Modifier and Type | Method and Description |
---|---|
void |
encodeBegin(FacesContext context)
If the
var attribute is set, start capturing the output. |
void |
encodeEnd(FacesContext context)
If the
var attribute is set, stop capturing the output and expose it in request scope by the
var attribute value as variable name. |
String |
getVar()
Returns the variable name which exposes the captured output into the request scope.
|
void |
setValueExpression(String name,
ValueExpression binding)
An override which checks if this isn't been invoked on
var or varNode attribute. |
void |
setVar(String var)
Sets the variable name which exposes the captured output into the request scope.
|
getDir, getLang, getStyle, getStyleClass, getTitle, isEscape, setDir, setEscape, setLang, setStyle, setStyleClass, setTitle
clearInitialState, getConverter, getFamily, getLocalValue, getValue, markInitialState, restoreState, saveState, setConverter, setValue
addClientBehavior, addFacesListener, broadcast, decode, encodeChildren, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getResourceBundleMap, getStateHelper, getStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, setInView, subscribeToEvent, unsubscribeFromEvent, visitTree
public static final String COMPONENT_TYPE
public void setValueExpression(String name, ValueExpression binding)
var
or varNode
attribute.
Finally it delegates to the super method.setValueExpression
in class UIComponent
IllegalArgumentException
- When this value expression is been set on var
or
varNode
attribute.public void encodeBegin(FacesContext context) throws IOException
var
attribute is set, start capturing the output.encodeBegin
in class UIComponentBase
IOException
public void encodeEnd(FacesContext context) throws IOException
var
attribute is set, stop capturing the output and expose it in request scope by the
var
attribute value as variable name.encodeEnd
in class UIComponentBase
IOException
public String getVar()
public void setVar(String var)
var
- The variable name which exposes the captured output into the request scope.