public class UIViewParameter extends UIInput
UIViewParameter represents a binding between a
request parameter and a model property or UIViewRoot
property. This is a bi-directional binding.
The ViewDeclarationLanguage
implementation must cause an instance of this component to
appear in the view for each occurrence of an <f:viewParam />
element placed inside of an
<f:metadata />
element. The user must place this facet within the UIViewRoot
.
Because this class extends UIInput
any actions that one would normally take on a UIInput
instance are valid for instances of this class. Instances of this class participate in the regular Jakarta Server
Faces lifecycle, including on Ajax requests.
Modifier and Type | Class and Description |
---|---|
static class |
UIViewParameter.Reference
Inner class to encapsulate a |
Modifier and Type | Field and Description |
---|---|
static String |
COMPONENT_FAMILY
The standard component family for this component.
|
static String |
COMPONENT_TYPE
The standard component type for this component.
|
ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE, CONVERSION_MESSAGE_ID, EMPTY_STRING_AS_NULL_PARAM_NAME, REQUIRED_MESSAGE_ID, UPDATE_MESSAGE_ID, VALIDATE_EMPTY_FIELDS_PARAM_NAME
ATTRS_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 |
---|
UIViewParameter()
Create a new
UIViewParameter instance with default property values. |
Modifier and Type | Method and Description |
---|---|
void |
decode(FacesContext context)
Override behavior from superclass to pull a value from the incoming request parameter map under the name given by
|
void |
encodeAll(FacesContext context)
Called specially by |
protected Object |
getConvertedValue(FacesContext context,
Object submittedValue)
Because this class has no |
String |
getFamily()
Return the identifier of the component family to which this component belongs. |
String |
getName()
Return the request parameter name from which the value is retrieved. |
String |
getStringValue(FacesContext context)
If the value of this parameter comes from a |
String |
getStringValueFromModel(FacesContext context)
Manually perform standard conversion steps to get a string value from the value expression. |
Object |
getSubmittedValue()
Assume that the submitted value is always a string,
but the return type from this method is |
boolean |
isImmediate()
Return |
void |
processValidators(FacesContext context)
Specialize superclass behavior to treat |
void |
setName(String name)
Set the request parameter name from which the value is retrieved. |
void |
setSubmittedValue(Object submittedValue)
PENDING (docs) Interesting that submitted value isn't saved by the parent
|
void |
updateModel(FacesContext context)
Call through to superclass |
addValidator, addValueChangeListener, clearInitialState, compareValues, getConverterMessage, getRequiredMessage, getValidator, getValidatorMessage, getValidators, getValue, getValueChangeListener, getValueChangeListeners, isEmpty, isLocalValueSet, isRequired, isValid, markInitialState, processDecodes, processUpdates, removeValidator, removeValueChangeListener, resetValue, restoreState, saveState, setConverterMessage, setImmediate, setLocalValueSet, setRequired, setRequiredMessage, setValid, setValidator, setValidatorMessage, setValue, setValueChangeListener, validate, validateValue
getConverter, getLocalValue, setConverter
addClientBehavior, addFacesListener, broadcast, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, 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, unsubscribeFromEvent
getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, visitTree
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConverter, getLocalValue, setConverter
public static final String COMPONENT_TYPE
The standard component type for this component.
public static final String COMPONENT_FAMILY
The standard component family for this component.
public UIViewParameter()
Create a new UIViewParameter
instance with default property values.
public String getFamily()
UIComponent
Return the identifier of the component family to which this component belongs. This identifier, in conjunction with
the value of the rendererType
property, may be used to select the appropriate Renderer
for this
component instance. Note this method should NOT return null
public String getName()
Return the request parameter name from which the value is retrieved.
public void setName(String name)
Set the request parameter name from which the value is retrieved.
name
- The new request parameter name.public boolean isImmediate()
Return false
. The immediate setting is not relevant for view parameters and must be assumed to be
false
.
isImmediate
in interface EditableValueHolder
isImmediate
in class UIInput
true
if immediate, false
otherwise.public Object getSubmittedValue()
Assume that the submitted value is always a string,
but the return type from this method is Object
..
getSubmittedValue
in interface EditableValueHolder
getSubmittedValue
in class UIInput
public void setSubmittedValue(Object submittedValue)
setSubmittedValue
in interface EditableValueHolder
setSubmittedValue
in class UIInput
submittedValue
- The new submitted valuepublic void decode(FacesContext context)
Override behavior from superclass to pull a value from the incoming request parameter map under the name given by
getName()
and store it with a call to UIInput.setSubmittedValue(java.lang.Object)
.
decode
in class UIInput
context
- FacesContext
for the request we are processingpublic void processValidators(FacesContext context)
Specialize superclass behavior to treat null
differently. In
this class, a null
value along with the "required" flag being set to true
will cause a
validation failure. Otherwise, If the UIInput.EMPTY_STRING_AS_NULL_PARAM_NAME
context parameter is true and the value is null
, call UIInput.setSubmittedValue(java.lang.Object)
passing the empty
string as the argument. This will cause the normal validation processing to happen, including bean validation.
processValidators
in class UIInput
context
- the Faces context.PreValidateEvent
,
PostValidateEvent
public void updateModel(FacesContext context)
Call through to superclass UIInput.updateModel(jakarta.faces.context.FacesContext)
then take the additional action of pushing the value into
request scope if and only if the value is not a value expression, is valid, and the local value was set on this
lifecycle execution.
updateModel
in class UIInput
context
- FacesContext
for the request we are processingpublic void encodeAll(FacesContext context) throws IOException
Called specially by UIViewRoot.encodeEnd(jakarta.faces.context.FacesContext)
, this method simply sets the submitted value to be the return from
getStringValue(jakarta.faces.context.FacesContext)
.
encodeAll
in class UIComponent
context
- the Faces context.IOException
- when an I/O error occurs.public String getStringValue(FacesContext context)
If the value of this parameter comes from a ValueExpression
return the value of the expression,
otherwise, return the local value.
context
- the Faces context.public String getStringValueFromModel(FacesContext context) throws ConverterException
Manually perform standard conversion steps to get a string value from the value expression.
context
- the Faces context.ConverterException
protected Object getConvertedValue(FacesContext context, Object submittedValue) throws ConverterException
Because this class has no Renderer
, leverage the one from the standard HTML_BASIC RenderKit
with
component-family: jakarta.faces.Input
and renderer-type: jakarta.faces.Text
and call its
Renderer.getConvertedValue(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent, java.lang.Object)
method.
getConvertedValue
in class UIInput
submittedValue
- the submitted value.context
- the Faces context.ConverterException
Copyright © 2018,2020 Eclipse Foundation.
Use is subject to license terms.