public class ViewParam extends UIViewParameter
The <o:viewParam> is a component that extends the standard <f:viewParam> and
provides a stateless mode of operation and fixes the issue wherein null model values are converted to empty string
parameters in query string (e.g. when includeViewParams=true) and the (bean) validation never being
triggered when the parameter is completely absent in query string, causing e.g. @NotNull to fail.
The standard UIViewParameter implementation calls the model setter again after postback. This is not always
desired when being bound to a view scoped bean and can lead to performance problems when combined with an expensive
converter. To solve this, this component by default stores the submitted value as a component property instead of in
the model (and thus in the view state in case the binding is to a view scoped bean).
The standard UIViewParameter implementation calls the converter and validators again on postbacks. This is
not always desired when you have e.g. a required="true", but the parameter is not retained on form
submit. You would need to retain it on every single command link/button by <f:param>. To solve
this, this component doesn't call the converter and validators again on postbacks. Further it also provides a default
for the label atrribute. When the label attribute is omitted, the name
attribute will be used as label.
The standard UIViewParameter implementation calls the converter regardless of whether the evaluated model
value is null or not. As converters by specification return an empty string in case of null
value, this is being added to the query string as an empty parameter when e.g. includeViewParams=true is
used. This is not desired. The workaround was added in OmniFaces 1.8.
The standard UIViewParameter implementation uses an internal "is required" check when the submitted value is
null, hereby completely bypassing the standard UIInput validation, including any bean
validation annotations and even the PreValidateEvent and PostValidateEvent events. This is not
desired. The workaround was added in OmniFaces 2.0.
You can use it the same way as <f:viewParam>, you only need to change f: to
o:.
<o:viewParam name="foo" value="#{bean.foo}" />
UIViewParameter.Reference| Modifier and Type | Field and Description |
|---|---|
static String |
COMPONENT_TYPE |
COMPONENT_FAMILYCONVERSION_MESSAGE_ID, REQUIRED_MESSAGE_ID, UPDATE_MESSAGE_ID, VALIDATE_EMPTY_FIELDS_PARAM_NAMEATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME, VIEW_LOCATION_KEY| Constructor and Description |
|---|
ViewParam() |
| Modifier and Type | Method and Description |
|---|---|
Map<String,Object> |
getAttributes() |
String |
getStringValueFromModel(FacesContext context)
When there's a value expression and the evaluated model value is
null, then just return
null instead of delegating to default implementation which would return an empty string when a
converter is attached. |
String |
getSubmittedValue() |
boolean |
isRequired() |
void |
processDecodes(FacesContext context) |
void |
processValidators(FacesContext context) |
void |
setSubmittedValue(Object submittedValue) |
decode, encodeAll, getConvertedValue, getFamily, getName, getStringValue, isImmediate, setName, updateModeladdValidator, addValueChangeListener, clearInitialState, compareValues, getConverterMessage, getRequiredMessage, getValidator, getValidatorMessage, getValidators, getValue, getValueChangeListener, getValueChangeListeners, isEmpty, isLocalValueSet, isValid, markInitialState, processUpdates, removeValidator, removeValueChangeListener, resetValue, restoreState, saveState, setConverterMessage, setImmediate, setLocalValueSet, setRequired, setRequiredMessage, setValid, setValidator, setValidatorMessage, setValue, setValueChangeListener, validate, validateValuegetConverter, getLocalValue, setConverteraddClientBehavior, addFacesListener, broadcast, encodeBegin, encodeChildren, encodeEnd, findComponent, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, subscribeToEvent, unsubscribeFromEventgetClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, visitTreeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetConverter, getLocalValue, setConverterpublic static final String COMPONENT_TYPE
public void setSubmittedValue(Object submittedValue)
setSubmittedValue in interface EditableValueHoldersetSubmittedValue in class UIViewParameterpublic String getSubmittedValue()
getSubmittedValue in interface EditableValueHoldergetSubmittedValue in class UIViewParameterpublic boolean isRequired()
isRequired in interface EditableValueHolderisRequired in class UIInputpublic void processDecodes(FacesContext context)
processDecodes in class UIInputpublic void processValidators(FacesContext context)
processValidators in class UIViewParameterpublic Map<String,Object> getAttributes()
getAttributes in class UIComponentBasepublic String getStringValueFromModel(FacesContext context) throws ConverterException
null, then just return
null instead of delegating to default implementation which would return an empty string when a
converter is attached.getStringValueFromModel in class UIViewParameterConverterExceptionCopyright © 2012–2014 OmniFaces. All rights reserved.