@JSFComponent(defaultRendererType="jakarta.faces.Text") public class UIInput extends UIOutput implements EditableValueHolder
See the javadoc for this class in the JSF Specification for further details.
Modifier and Type | Field and Description |
---|---|
static String |
ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE
If set to true, validation is always performed when required is true.
|
static String |
COMPONENT_FAMILY |
static String |
COMPONENT_TYPE |
static String |
CONVERSION_MESSAGE_ID |
static String |
EMPTY_STRING_AS_NULL_PARAM_NAME
Submitted values are decoded as null values instead empty strings.
|
static String |
REQUIRED_MESSAGE_ID |
static String |
UPDATE_MESSAGE_ID |
static String |
VALIDATE_EMPTY_FIELDS_PARAM_NAME
Force validation on empty fields (By default is auto, which means it is only
enabled when Bean Validation binaries are available on the current classpath).
|
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 |
---|
UIInput()
Construct an instance of the UIInput.
|
Modifier and Type | Method and Description |
---|---|
void |
addValidator(Validator validator)
See getValidator.
|
void |
addValueChangeListener(ValueChangeListener listener) |
void |
broadcast(FacesEvent event)
Invoke any listeners attached to this object which are listening for an event whose type matches the specified
event's runtime type.
|
void |
clearInitialState() |
protected boolean |
compareValues(Object previous,
Object value) |
void |
decode(FacesContext context)
Check the submitted form parameters for data associated with this component.
|
protected Object |
getConvertedValue(FacesContext context,
Object submittedValue)
Convert the provided object to the desired value.
|
String |
getConverterMessage()
Text to be displayed to the user as an error message when conversion of a submitted value to the target type
fails.
|
String |
getFamily() |
String |
getRequiredMessage()
Text to be displayed to the user as an error message when this component is marked as "required" but no input
data is present during a postback (ie the user left the required field blank).
|
Object |
getSubmittedValue()
Gets the current submitted value.
|
MethodBinding |
getValidator()
Deprecated.
|
String |
getValidatorMessage()
Text which will be shown if validation fails.
|
Validator[] |
getValidators()
See getValidator.
|
Object |
getValue()
Return the current value of this component.
|
MethodBinding |
getValueChangeListener()
A method which is invoked during postback processing for the current view if the submitted value for this
component is not equal to the value which the "value" expression for this component returns.
|
ValueChangeListener[] |
getValueChangeListeners()
The valueChange event is delivered when the value attribute
is changed.
|
static boolean |
isEmpty(Object value)
Check if a value is empty or not.
|
boolean |
isImmediate()
A boolean value that identifies the phase during which action events should fire.
|
boolean |
isLocalValueSet()
Specifies whether a local value is currently set.
|
boolean |
isRequired()
A boolean value that indicates whether an input value is required.
|
boolean |
isValid()
Specifies whether the component's value is currently valid, ie whether the validators attached to this component
have allowed it.
|
void |
markInitialState() |
void |
processDecodes(FacesContext context)
Set the "submitted value" of this component from the relevant data in the current servlet request object.
|
void |
processUpdates(FacesContext context)
This isn't an input component, so just pass on the processUpdates call to child components and facets that might
be input components.
|
void |
processValidators(FacesContext context) |
void |
removeValidator(Validator validator)
See getValidator.
|
void |
removeValueChangeListener(ValueChangeListener listener) |
void |
resetValue()
Convenience method to reset this component's value to an uninitialized state, by resetting the local value and
submitted values to null (ensuring that
EditableValueHolder.isLocalValueSet() is false), and setting "valid" to true. |
void |
restoreState(FacesContext facesContext,
Object state)
Invoked in the "restore view" phase, this initialises this object's members from the values saved previously into
the provided state object.
|
Object |
saveState(FacesContext facesContext)
Invoked after the render phase has completed, this method returns an object which can be passed to the
restoreState of some other instance of UIComponentBase to reset that object's state to the same values as this
object currently has.
|
void |
setConverterMessage(String converterMessage) |
void |
setImmediate(boolean immediate) |
void |
setLocalValueSet(boolean localValueSet)
Specify the return value of method isLocalValueSet.
|
void |
setRequired(boolean required)
Set to true to cause validation failure when a form containing this component is submitted and there is no value
selected for this component.
|
void |
setRequiredMessage(String requiredMessage) |
void |
setSubmittedValue(Object submittedValue)
Invoked during the "decode" phase of processing to inform this component what data was received from the user.
|
void |
setValid(boolean valid) |
void |
setValidator(MethodBinding validator)
Deprecated.
|
void |
setValidatorMessage(String validatorMessage) |
void |
setValue(Object value)
Store the specified object as the "local value" of this component.
|
void |
setValueChangeListener(MethodBinding valueChangeListener)
Deprecated.
Use addValueChangeListener instead
|
void |
updateModel(FacesContext context) |
void |
validate(FacesContext context)
Determine whether the new value is valid, and queue a ValueChangeEvent if necessary.
|
protected void |
validateValue(FacesContext context,
Object convertedValue) |
getConverter, getLocalValue, setConverter
addClientBehavior, addFacesListener, encodeAll, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getPassThroughAttributes, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, visitTree
getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, subscribeToEvent, unsubscribeFromEvent
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConverter, getLocalValue, setConverter
public static final String COMPONENT_TYPE
public static final String COMPONENT_FAMILY
public static final String CONVERSION_MESSAGE_ID
public static final String REQUIRED_MESSAGE_ID
public static final String UPDATE_MESSAGE_ID
@JSFWebConfigParam(defaultValue="auto", expectedValues="auto, true, false", since="2.0", group="validation") public static final String VALIDATE_EMPTY_FIELDS_PARAM_NAME
@JSFWebConfigParam(defaultValue="false", expectedValues="true, false", since="2.0", group="validation") public static final String EMPTY_STRING_AS_NULL_PARAM_NAME
Note this param is ignored for components extending from UISelectOne/UISelectMany.
@JSFWebConfigParam(defaultValue="false", expectedValues="true, false", since="2.3", group="validation") public static final String ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE
public void setValue(Object value)
setValue
in interface ValueHolder
setValue
in class UIOutput
public Object getValue()
If a submitted value has been converted but not yet pushed into the model, then return that locally-cached value (see isLocalValueSet).
Otherwise, evaluate an EL expression to fetch a value from the model.
getValue
in interface ValueHolder
getValue
in class UIOutput
public void processDecodes(FacesContext context)
If this component is not rendered, then do nothing; no output would have been sent to the client so no input is expected.
Invoke the inherited functionality, which typically invokes the renderer associated with this component to extract and set this component's "submitted value".
If this component is marked "immediate", then immediately apply validation to the submitted value found. On error, call context method "renderResponse" which will force processing to leap to the "render response" phase as soon as the "decode" step has completed for all other components.
processDecodes
in class UIComponentBase
public void processValidators(FacesContext context)
processValidators
in class UIComponentBase
public void processUpdates(FacesContext context)
UIComponentBase
Components that were never rendered can't possibly be receiving update data (no corresponding fields were ever put into the response) so if this component is not rendered then this method does not invoke processUpdates on its children.
processUpdates
in class UIComponentBase
public void decode(FacesContext context)
UIComponentBase
decode
in class UIComponentBase
public void broadcast(FacesEvent event) throws AbortProcessingException
UIComponentBase
This method does not propagate the event up to parent components, ie listeners attached to parent components don't automatically get called.
If any of the listeners throws AbortProcessingException then that exception will prevent any further listener callbacks from occurring, and the exception propagates out of this method without alteration.
ActionEvent events are typically queued by the renderer associated with this component in its decode method; ValueChangeEvent events by the component's validate method. In either case the event's source property references a component. At some later time the UIViewRoot component iterates over its queued events and invokes the broadcast method on each event's source object.
broadcast
in class UIComponentBase
event
- must not be null.AbortProcessingException
public void updateModel(FacesContext context)
protected void validateValue(FacesContext context, Object convertedValue)
public void validate(FacesContext context)
The "submitted value" is converted to the necessary type; conversion failure is reported as an error and validation processing terminates for this component. See documentation for method getConvertedValue for details on the conversion process.
Any validators attached to this component are then run, passing the converted value.
The old value of this component is then fetched (possibly involving the evaluation of a value-binding expression, ie invoking a method on a user object). The old value is compared to the new validated value, and if they are different then a ValueChangeEvent is queued for later processing.
On successful completion of this method:
protected Object getConvertedValue(FacesContext context, Object submittedValue) throws ConverterException
If there is a renderer for this component, then call the renderer's getConvertedValue method. While this can of course be implemented in any way the renderer desires, it typically performs exactly the same processing that this method would have done anyway (ie that described below for the no-renderer case).
Otherwise:
ConverterException
public void resetValue()
EditableValueHolder
EditableValueHolder.isLocalValueSet()
is false), and setting "valid" to true.resetValue
in interface EditableValueHolder
resetValue
in class UIOutput
@JSFProperty public boolean isImmediate()
During normal event processing, action methods and action listener methods are fired during the "invoke application" phase of request processing. If this attribute is set to "true", these methods are fired instead at the end of the "apply request values" phase.
isImmediate
in interface EditableValueHolder
public void setImmediate(boolean immediate)
setImmediate
in interface EditableValueHolder
@JSFProperty(defaultValue="false") public boolean isRequired()
If this value is true and no input value is provided by a postback operation, then the "requiredMessage" text is registered as a FacesMessage for the request, and validation fails.
Default value: false.
isRequired
in interface EditableValueHolder
public void setRequired(boolean required)
EditableValueHolder
setRequired
in interface EditableValueHolder
@JSFProperty public String getConverterMessage()
public void setConverterMessage(String converterMessage)
@JSFProperty public String getRequiredMessage()
public void setRequiredMessage(String requiredMessage)
@Deprecated @JSFProperty(stateHolder=true, returnSignature="void", methodSignature="jakarta.faces.context.FacesContext,jakarta.faces.component.UIComponent,java.lang.Object") public MethodBinding getValidator()
The invoked method is expected to check the submitted value for this component, and if not acceptable then report a validation error for the component.
The method is expected to have the prototype
public void aMethod(FacesContext, UIComponent,Object)
getValidator
in interface EditableValueHolder
@Deprecated public void setValidator(MethodBinding validator)
setValidator
in interface EditableValueHolder
public void addValidator(Validator validator)
addValidator
in interface EditableValueHolder
public void removeValidator(Validator validator)
removeValidator
in interface EditableValueHolder
public Validator[] getValidators()
getValidators
in interface EditableValueHolder
@JSFProperty public String getValidatorMessage()
public void setValidatorMessage(String validatorMessage)
@JSFProperty(stateHolder=true, returnSignature="void", methodSignature="jakarta.faces.event.ValueChangeEvent", clientEvent="valueChange") public MethodBinding getValueChangeListener()
The phase in which this method is invoked can be controlled via the immediate attribute.
getValueChangeListener
in interface EditableValueHolder
@Deprecated public void setValueChangeListener(MethodBinding valueChangeListener)
setValueChangeListener
in interface EditableValueHolder
@JSFProperty(defaultValue="true", tagExcluded=true) public boolean isValid()
isValid
in interface EditableValueHolder
public void setValid(boolean valid)
setValid
in interface EditableValueHolder
@JSFProperty(defaultValue="false", tagExcluded=true) public boolean isLocalValueSet()
If false, values are being retrieved from any attached ValueBinding.
isLocalValueSet
in interface EditableValueHolder
public void setLocalValueSet(boolean localValueSet)
EditableValueHolder
setLocalValueSet
in interface EditableValueHolder
@JSFProperty(tagExcluded=true) public Object getSubmittedValue()
getSubmittedValue
in interface EditableValueHolder
public void setSubmittedValue(Object submittedValue)
EditableValueHolder
In many cases the submitted value is a plain string extracted from the current servlet request object.
In cases where a component is rendered as multiple input components (eg a calendar control with separate day/month/year fields), the submittedValue may be some custom object wrapping the data. However the provided object must be able to represent all possible user input values, not just valid ones.
setSubmittedValue
in interface EditableValueHolder
public void addValueChangeListener(ValueChangeListener listener)
addValueChangeListener
in interface EditableValueHolder
public void removeValueChangeListener(ValueChangeListener listener)
removeValueChangeListener
in interface EditableValueHolder
@JSFListener(event="jakarta.faces.event.ValueChangeEvent") public ValueChangeListener[] getValueChangeListeners()
getValueChangeListeners
in interface EditableValueHolder
public void markInitialState()
markInitialState
in interface PartialStateHolder
markInitialState
in class UIOutput
public void clearInitialState()
UIComponent
clearInitialState
in interface PartialStateHolder
clearInitialState
in class UIOutput
public Object saveState(FacesContext facesContext)
UIComponentBase
saveState
in interface StateHolder
saveState
in class UIOutput
public void restoreState(FacesContext facesContext, Object state)
UIComponentBase
restoreState
in interface StateHolder
restoreState
in class UIOutput
state
- is an object previously returned by the saveState method of this class.public static boolean isEmpty(Object value)
value
- Copyright © 2021 The Apache Software Foundation. All rights reserved.