Class UIViewParameter
- All Implemented Interfaces:
EditableValueHolder, PartialStateHolder, StateHolder, TransientStateHolder, ValueHolder, ComponentSystemEventListener, FacesListener, SystemEventListenerHolder, EventListener
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.
- Since:
- 2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classInner class to encapsulate aUIViewParameterinstance so that it may be safely referenced regardless of whether or not the current view is the same as the view in which thisUIViewParameterresides.Nested classes/interfaces inherited from class UIInput
UIInput.ValidateEmptyFieldsModifier and TypeClassDescriptionstatic enumAllowed values for the initialization parameter named by the "jakarta.faces.VALIDATE_EMPTY_FIELDS" constant. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe standard component family for this component.static final StringThe standard component type for this component.Fields inherited from class UIInput
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_NAMEModifier and TypeFieldDescriptionstatic final StringIf this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, validation must be performed, even when there is no corresponding value for this component in the incoming request.static final StringThe message identifier of theFacesMessageto be created if a conversion error occurs, and neither the page author nor theConverterExceptionprovides a message.static final StringThe name of a context parameter that indicates how empty strings need to be interpreted.static final StringThe message identifier of theFacesMessageto be created if a required check fails.static final StringThe message identifier of theFacesMessageto be created if a model update error occurs, and the thrown exception has no message.static final StringThe name of a context parameter that indicates how empty values should be handled with respect to validation.Fields inherited from class UIComponent
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, FACETS_KEY, VIEW_LOCATION_KEYModifier and TypeFieldDescriptionstatic final StringThis constant enables one to quickly discover the names of the declared composite component attributes that have been given default values by the composite component author.static final StringThe value of this constant is used as the key in the component attribute map, the value for which is ajava.beans.BeanInfoimplementation describing the composite component.static final StringThe value of this constant is used as the key in the composite component BeanDescriptor for aValueExpressionthat evaluates to thecomponent-typeof the composite component rootUIComponentfor this composite component, if one was declared by the composite component author.static final StringThe value of this constant is used as the key in theMapreturned as described inUIComponent.FACETS_KEYfor thePropertyDescriptordescribing the composite component facet.static final StringThe value of this constant is used as the key in the composite component BeanDescriptor for theMap<PropertyDescriptor>that contains meta-information for the declared facets for this composite component.static final StringThe value of this constant is used as the key in the component attributesMapfor theLocationin the view at which this component instance resides. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddecode(FacesContext context) Override behavior from superclass to pull a value from the incoming request parameter map under the name given bygetName()and store it with a call toUIInput.setSubmittedValue(Object).voidencodeAll(FacesContext context) Called specially byUIViewRoot.encodeEnd(FacesContext), this method simply sets the submitted value to be the return fromgetStringValue(FacesContext).protected ObjectgetConvertedValue(FacesContext context, Object submittedValue) Because this class has noRenderer, leverage the one from the standard HTML_BASICRenderKitwithcomponent-family: jakarta.faces.Inputandrenderer-type: jakarta.faces.Textand call itsRenderer.getConvertedValue(FacesContext, T, Object)method.Return the identifier of the component family to which this component belongs.getName()Return the request parameter name from which the value is retrieved.getStringValue(FacesContext context) If the value of this parameter comes from aValueExpressionreturn the value of the expression, otherwise, return the local value.getStringValueFromModel(FacesContext context) Manually perform standard conversion steps to get a string value from the value expression.Assume that the submitted value is always a string, but the return type from this method isObject..booleanReturnfalse.voidprocessValidators(FacesContext context) Specialize superclass behavior to treatnulldifferently.voidSet the request parameter name from which the value is retrieved.voidsetSubmittedValue(Object submittedValue) PENDING (docs) Interesting that submitted value isn't saved by the parentvoidupdateModel(FacesContext context) Call through to superclassUIInput.updateModel(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.Methods inherited from class UIInput
addValidator, addValueChangeListener, clearInitialState, compareValues, getConverterMessage, getRequiredMessage, getValidatorMessage, getValidators, getValue, getValueChangeListeners, isEmpty, isLocalValueSet, isRequired, isValid, markInitialState, processDecodes, processUpdates, removeValidator, removeValueChangeListener, resetValue, restoreState, saveState, setConverterMessage, setImmediate, setLocalValueSet, setRequired, setRequiredMessage, setValid, setValidatorMessage, setValue, validate, validateValueModifier and TypeMethodDescriptionvoidaddValidator(Validator validator) voidaddValueChangeListener(ValueChangeListener listener) Add a newValueChangeListenerto the set of listeners interested in being notified whenValueChangeEvents occur.voidFor each of the attached objects on this instance that implementPartialStateHolder, callPartialStateHolder.clearInitialState()on the attached object.protected booleancompareValues(Object previous, Object value) Returntrueif the new value is different from the previous value.If there has been a call toUIInput.setConverterMessage(String)on this instance, return the message.If there has been a call toUIInput.setRequiredMessage(String)on this instance, return the message.If there has been a call toUIInput.setValidatorMessage(String)on this instance, return the message.getValue()If there is a local value, return it, otherwise return the result of callingsuper.getValue().Return the set of registeredValueChangeListeners for thisUIInputinstance.static booleanIs the value denoting an empty value.booleanReturn the "local value set" state for this component.booleanReturn the "required field" state for this component.booleanisValid()Return a flag indicating whether the local value of this component is valid (no conversion error has occurred).voidIn addition to the actions taken inUIOutputwhenPartialStateHolder.markInitialState()is called, check if any of the installedValidators are PartialStateHolders and if so, callPartialStateHolder.markInitialState()as appropriate.voidprocessDecodes(FacesContext context) Specialized decode behavior on top of that provided by the superclass.voidprocessUpdates(FacesContext context) In addition to the standardprocessUpdatesbehavior inherited fromUIComponentBase, callsupdateModel().voidremoveValidator(Validator validator) voidremoveValueChangeListener(ValueChangeListener listener) Remove an existingValueChangeListener(if any) from the set of listeners interested in being notified whenValueChangeEvents occur.voidConvenience method to reset this component's value to the un-initialized state.voidrestoreState(FacesContext context, Object state) Perform any processing required to restore the state from the entries in the state Object.saveState(FacesContext context) Gets the state of the instance as aSerializableObject.voidsetConverterMessage(String message) Override anyValueExpressionset for the "converterMessage" with the literal argument provided to this method.voidsetImmediate(boolean immediate) Set the "immediate" state for this component.voidsetLocalValueSet(boolean localValueSet) Sets the "local value set" state for this component.voidsetRequired(boolean required) Set the "required field" state for this component.voidsetRequiredMessage(String message) Override anyValueExpressionset for the "requiredMessage" with the literal argument provided to this method.voidsetValid(boolean valid) Set a flag indicating whether the local value of this component is valid (no conversion error has occurred).voidsetValidatorMessage(String message) Override anyValueExpressionset for the "validatorMessage" with the literal argument provided to this method.voidSet the value of thisUIComponent(if any).voidvalidate(FacesContext context) Perform the following algorithm to validate the local value of thisUIInput.protected voidvalidateValue(FacesContext context, Object newValue) Set the "valid" property according to the below algorithm.Methods inherited from class UIOutput
getConverter, getLocalValue, setConverterModifier and TypeMethodDescriptionReturn theConverter(if any) that is registered for thisUIComponent.Return the local value of thisUIComponent(if any), without evaluating any associatedValueExpression.voidsetConverter(Converter converter) Set theConverter(if any) that is registered for thisUIComponent.Methods inherited from class UIComponentBase
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, invokeOnComponent, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, subscribeToEvent, unsubscribeFromEventModifier and TypeMethodDescriptionvoidaddClientBehavior(String eventName, ClientBehavior behavior) This is a default implementation ofClientBehaviorHolder.addClientBehavior(String, ClientBehavior).protected voidaddFacesListener(FacesListener listener) Add the specifiedFacesListenerto the set of listeners registered to receive event notifications from thisUIComponent.voidbroadcast(FacesEvent event) Broadcast the specifiedFacesEventto all registered event listeners who have expressed an interest in events of this type.voidencodeBegin(FacesContext context) If ourrenderedproperty istrue, render the beginning of the current state of thisUIComponentto the response contained in the specifiedFacesContext.voidencodeChildren(FacesContext context) voidencodeEnd(FacesContext context) findComponent(String expression) Search for and return theUIComponentwith anidthat matches the specified search expression (if any), according to the algorithm described below.Return a mutableMaprepresenting the attributes (and properties, see below) associated wth thisUIComponent, keyed by attribute name (which must be a String).intReturn the number of childUIComponents that are associated with thisUIComponent.This is a default implementation ofClientBehaviorHolder.getClientBehaviors().getClientId(FacesContext context) Return a client-side identifier for this component, generating one if necessary.This is a default implementation ofClientBehaviorHolder.getDefaultEventName().This is a default implementation ofClientBehaviorHolder.getEventNames().protected FacesContextConvenience method to return theFacesContextinstance for the current request.protected FacesListener[]getFacesListeners(Class clazz) Return an array of registeredFacesListeners that are instances of the specified class.Convenience method to return the named facet, if it exists, ornullotherwise.intReturn the number of facetUIComponents that are associated with thisUIComponent.Return a mutableMaprepresenting the facetUIComponents associated with thisUIComponent, keyed by facet name (which must be a String).getId()Return the component identifier of thisUIComponent.getListenersForEventClass(Class<? extends SystemEvent> eventClass) Return theSystemEventListenerinstances registered on thisUIComponentinstance that are interested in events of typeeventClass.Return the parentUIComponentof thisUIComponent, if any.getPassThroughAttributes(boolean create) This method has the same specification asUIComponent.getPassThroughAttributes()except that it is allowed to returnnullif and only if the argumentcreateisfalseand no pass through attribute data structure exists for this instance.protected RenderergetRenderer(FacesContext context) Convenience method to return theRendererinstance associated with this component, if any; otherwise, returnnull.Return theRenderertype for thisUIComponent(if any).booleanReturn a flag indicating whether this component is responsible for rendering its child components.booleaninvokeOnComponent(FacesContext context, String clientId, ContextCallback callback) Starting at this component in the View hierarchy, search for a component with aclientIdequal to the argumentclientIdand, if found, call theContextCallback.invokeContextCallback(FacesContext, UIComponent)method on the argumentcallback, passing the currentFacesContextand the found component as arguments.booleanReturntrueif this component (and its children) should be rendered during the Render Response phase of the request processing lifecycle.booleanIf true, the Object implementing this interface must not participate in state saving or restoring.voidprocessRestoreState(FacesContext context, Object state) Perform the component tree processing required by the Restore View phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.processSaveState(FacesContext context) Perform the component tree processing required by the state saving portion of the Render Response phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.voidqueueEvent(FacesEvent event) Queue an event for broadcast at the end of the current request processing lifecycle phase.protected voidremoveFacesListener(FacesListener listener) Remove the specifiedFacesListenerfrom the set of listeners registered to receive event notifications from thisUIComponent.static ObjectrestoreAttachedState(FacesContext context, Object stateObj) This method is called byUIComponentsubclasses that need to restore the objects they saved usingUIComponentBase.saveAttachedState(FacesContext, Object).static ObjectsaveAttachedState(FacesContext context, Object attachedObject) This method is called byUIComponentsubclasses that want to save one or more attached objects.voidSet the component identifier of thisUIComponent(if any).voidsetParent(UIComponent parent) Set the parentUIComponentof thisUIComponent.voidsetRendered(boolean rendered) Set therenderedproperty of thisUIComponent.voidsetRendererType(String rendererType) voidsetTransient(boolean transientFlag) Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.voidsubscribeToEvent(Class<? extends SystemEvent> eventClass, ComponentSystemEventListener componentListener) Install the listener instance referenced by argumentcomponentListeneras a listener for events of typeeventClassoriginating from this specific instance ofUIComponent.voidunsubscribeFromEvent(Class<? extends SystemEvent> eventClass, ComponentSystemEventListener componentListener) Remove the listener instance referenced by argumentcomponentListeneras a listener for events of typeeventClassoriginating from this specific instance ofUIComponent.Methods inherited from class UIComponent
getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getFacet, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, visitTreeModifier and TypeMethodDescriptionEnable Jakarta Expression Language to access theclientIdof a component.static UIComponentgetCompositeComponentParent(UIComponent component) Finds the nearest composite component parent of the specified component.getContainerClientId(FacesContext context) Allow components that implementNamingContainerto selectively disable prepending their clientId to their descendent's clientIds by breaking the prepending logic into a separately callable method.static UIComponentgetCurrentComponent(FacesContext context) Return theUIComponentinstance that is currently processing.static UIComponentgetCurrentCompositeComponent(FacesContext context) Return the closest ancestor component, relative to the component returned fromUIComponent.getCurrentComponent(FacesContext), that is a composite component, ornullif no such component exists.Convenience method to return the named facet using an enum identifier, if it exists, ornullotherwise.Starting with "this", return the closest component in the ancestry that is aNamingContainerornullif none can be found.This is a convenience method that simply callsUIComponent.getPassThroughAttributes(boolean), passingtrueas the argument.Return aMap<String,String>of theResourceBundlefor this component.protected StateHelperReturn theStateHelperinstance used to help this component implementPartialStateHolder.protected StateHelpergetStateHelper(boolean create) LikeUIComponent.getStateHelper(), but only create a state helper instance if the argumentcreatistrue.Return theTransientStateHelperinstance for thisUIComponentinstance.getTransientStateHelper(boolean create) Return theTransientStateHelperinstance for thisUIComponentinstance.jakarta.el.ValueExpressiongetValueExpression(String name) Return theValueExpressionused to calculate the value for the specified attribute or property name, if any.booleanAn implementation ofPartialStateHolder.initialStateMarked(), this method is called by the runtime to test if thePartialStateHolder.markInitialState()method was called.static booleanisCompositeComponent(UIComponent component) Returntrueifcomponentis a composite component, otherwisefalse.booleanisInView()Returntrueif this component is within the view hierarchy otherwisefalseprotected booleanisVisitable(VisitContext context) Returntrueif this component should be visited,falseotherwise.voidpopComponentFromEL(FacesContext context) Pop the currentUIComponentfrom theFacesContextattributes map so that the previousUIComponent, if any, becomes the current component.voidprocessEvent(ComponentSystemEvent event) The default implementation performs the following action.voidpushComponentToEL(FacesContext context, UIComponent component) Push the currentUIComponentthisto theFacesContextattribute map saving the previousUIComponentfor a subsequent call toUIComponent.popComponentFromEL(FacesContext).voidrestoreTransientState(FacesContext context, Object state) For components that need to support the concept of transient state, this method will restore any state saved on a prior call toUIComponent.saveTransientState(FacesContext).saveTransientState(FacesContext context) For components that need to support the concept of transient state, this method will save any state that is known to be transient in nature.voidsetInView(boolean isInView) Updates the status as to whether or not this component is currently within the view hierarchy.voidsetValueExpression(String name, jakarta.el.ValueExpression binding) Set theValueExpressionused to calculate the value for the specified attribute or property name, if any.booleanvisitTree(VisitContext visitContext, VisitCallback callback) Perform a tree visit starting at this node in the tree.
-
Field Details
-
COMPONENT_TYPE
-
COMPONENT_FAMILY
The standard component family for this component.
- See Also:
-
-
Constructor Details
-
UIViewParameter
public UIViewParameter()Create a new
UIViewParameterinstance with default property values.
-
-
Method Details
-
getFamily
Description copied from class:UIComponentReturn the identifier of the component family to which this component belongs. This identifier, in conjunction with the value of the
rendererTypeproperty, may be used to select the appropriateRendererfor this component instance. Note this method should NOT returnnull -
getName
Return the request parameter name from which the value is retrieved.
- Returns:
- the name.
- Since:
- 2.0
-
setName
Set the request parameter name from which the value is retrieved.
- Parameters:
name- The new request parameter name.- Since:
- 2.0
-
isImmediate
public boolean isImmediate()Return
false. The immediate setting is not relevant for view parameters and must be assumed to befalse.- Specified by:
isImmediatein interfaceEditableValueHolder- Overrides:
isImmediatein classUIInput- Returns:
trueif immediate,falseotherwise.- Since:
- 2.0
-
getSubmittedValue
Assume that the submitted value is always a string, but the return type from this method is
Object..- Specified by:
getSubmittedValuein interfaceEditableValueHolder- Overrides:
getSubmittedValuein classUIInput- Returns:
- the submitted value.
- Since:
- 2.0
-
setSubmittedValue
PENDING (docs) Interesting that submitted value isn't saved by the parent- Specified by:
setSubmittedValuein interfaceEditableValueHolder- Overrides:
setSubmittedValuein classUIInput- Parameters:
submittedValue- The new submitted value
-
decode
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 toUIInput.setSubmittedValue(Object).- Overrides:
decodein classUIInput- Parameters:
context-FacesContextfor the request we are processing- Since:
- 2.0
-
processValidators
Specialize superclass behavior to treat
nulldifferently. In this class, anullvalue along with the "required" flag being set totruewill cause a validation failure. Otherwise, If theUIInput.EMPTY_STRING_AS_NULL_PARAM_NAMEcontext parameter is true and the value isnull, callUIInput.setSubmittedValue(Object)passing the empty string as the argument. This will cause the normal validation processing to happen, including bean validation.- Overrides:
processValidatorsin classUIInput- Parameters:
context- the Faces context.- Since:
- 2.0
- See Also:
-
updateModel
Call through to superclass
UIInput.updateModel(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.- Overrides:
updateModelin classUIInput- Parameters:
context-FacesContextfor the request we are processing- Since:
- 2.0
-
encodeAll
Called specially by
UIViewRoot.encodeEnd(FacesContext), this method simply sets the submitted value to be the return fromgetStringValue(FacesContext).- Overrides:
encodeAllin classUIComponent- Parameters:
context- the Faces context.- Throws:
IOException- when an I/O error occurs.- Since:
- 2.0
-
getStringValue
If the value of this parameter comes from a
ValueExpressionreturn the value of the expression, otherwise, return the local value.- Parameters:
context- the Faces context.- Returns:
- the string value.
- Since:
- 2.0
-
getStringValueFromModel
Manually perform standard conversion steps to get a string value from the value expression.
- Parameters:
context- the Faces context.- Returns:
- the string value from the model.
- Throws:
ConverterException- Since:
- 2.0
-
getConvertedValue
protected Object getConvertedValue(FacesContext context, Object submittedValue) throws ConverterException Because this class has no
Renderer, leverage the one from the standard HTML_BASICRenderKitwithcomponent-family: jakarta.faces.Inputandrenderer-type: jakarta.faces.Textand call itsRenderer.getConvertedValue(FacesContext, T, Object)method.- Overrides:
getConvertedValuein classUIInput- Parameters:
context- the Faces context.submittedValue- the submitted value.- Returns:
- the converted value.
- Throws:
ConverterException- Since:
- 2.0
-