public class ViewParam
extends javax.faces.component.UIViewParameter
UIViewParameter 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 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. This is not desired.
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.
You can use it the same way as <f:viewParam>, you only need to change f: to
o:.
| Modifier and Type | Field and Description |
|---|---|
static String |
COMPONENT_TYPE |
| Constructor and Description |
|---|
ViewParam() |
| Modifier and Type | Method and Description |
|---|---|
Map<String,Object> |
getAttributes() |
String |
getStringValueFromModel(javax.faces.context.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(javax.faces.context.FacesContext context) |
void |
processValidators(javax.faces.context.FacesContext context) |
void |
setSubmittedValue(Object submittedValue) |
decode, encodeAll, getConvertedValue, getFamily, getName, getStringValue, isImmediate, setName, updateModeladdValidator, addValueChangeListener, clearInitialState, compareValues, getConverterMessage, getRequiredMessage, getValidator, getValidatorMessage, getValidators, 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, getValue, setConverteraddClientBehavior, addFacesListener, broadcast, encodeBegin, encodeChildren, encodeEnd, findComponent, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBindinggetClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getResourceBundleMap, getStateHelper, getStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, setInView, setValueExpression, subscribeToEvent, unsubscribeFromEvent, visitTreepublic static final String COMPONENT_TYPE
public void setSubmittedValue(Object submittedValue)
setSubmittedValue in interface javax.faces.component.EditableValueHoldersetSubmittedValue in class javax.faces.component.UIViewParameterpublic String getSubmittedValue()
getSubmittedValue in interface javax.faces.component.EditableValueHoldergetSubmittedValue in class javax.faces.component.UIViewParameterpublic boolean isRequired()
isRequired in interface javax.faces.component.EditableValueHolderisRequired in class javax.faces.component.UIInputpublic void processDecodes(javax.faces.context.FacesContext context)
processDecodes in class javax.faces.component.UIInputpublic void processValidators(javax.faces.context.FacesContext context)
processValidators in class javax.faces.component.UIViewParameterpublic Map<String,Object> getAttributes()
getAttributes in class javax.faces.component.UIComponentBasepublic String getStringValueFromModel(javax.faces.context.FacesContext context) throws javax.faces.convert.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 javax.faces.component.UIViewParameterjavax.faces.convert.ConverterExceptionCopyright © 2012–2014 OmniFaces. All rights reserved.