javax.faces.component
Class UIInput

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by javax.faces.component.UIOutput
              extended by javax.faces.component.UIInput
All Implemented Interfaces:
EditableValueHolder, StateHolder, ValueHolder
Direct Known Subclasses:
HtmlInputHidden, HtmlInputSecret, HtmlInputText, HtmlInputTextarea, UISelectBoolean, UISelectMany, UISelectOne

public class UIInput
extends UIOutput
implements EditableValueHolder

Events:

Type Phases Description
javax.faces.event.ValueChangeEvent The valueChange event is delivered when the value attribute is changed.


Field Summary
static java.lang.String COMPONENT_FAMILY
           
static java.lang.String COMPONENT_TYPE
           
static java.lang.String CONVERSION_MESSAGE_ID
           
static java.lang.String REQUIRED_MESSAGE_ID
           
static java.lang.String UPDATE_MESSAGE_ID
           
 
Fields inherited from class javax.faces.component.UIComponent
bindings
 
Constructor Summary
UIInput()
          Construct an instance of the UIInput.
 
Method Summary
 void addValidator(Validator validator)
          Adds a A method which is invoked during the validation phase for this component.
 void addValueChangeListener(ValueChangeListener listener)
          Adds a valueChange 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.
protected  boolean compareValues(java.lang.Object previous, java.lang.Object value)
           
 void decode(FacesContext context)
          Check the submitted form parameters for data associated with this component.
protected  java.lang.Object getConvertedValue(FacesContext context, java.lang.Object submittedValue)
          Convert the provided object to the desired value.
 java.lang.String getConverterMessage()
          Gets Text of the converter message.
 java.lang.String getFamily()
           
 java.lang.String getRequiredMessage()
          Gets Text which will be shown if a required value is not submitted.
 java.lang.Object getSubmittedValue()
          Gets the current submitted value.
 MethodBinding getValidator()
          Deprecated.  
 java.lang.String getValidatorMessage()
          Gets Text which will be shown, if validation fails.
 Validator[] getValidators()
          Gets all A method which is invoked during the validation phase for this component.
 MethodBinding getValueChangeListener()
          Deprecated.  
 ValueChangeListener[] getValueChangeListeners()
          Returns an array of attached valueChange listeners.
 boolean isImmediate()
          Gets A boolean value that identifies the phase during which action events should fire.
 boolean isLocalValueSet()
          Gets whether a local value is currently set.
 boolean isRequired()
          Gets A boolean value that indicates whether a value is required.
 boolean isValid()
          Gets whether the component's value is currently valid
 void processDecodes(FacesContext context)
          Set the "submitted value" of this component from the relevant data in the current servet 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)
          Removes a A method which is invoked during the validation phase for this component.
 void removeValueChangeListener(ValueChangeListener listener)
          Removes a valueChange listener.
 void resetValue()
           
 void restoreState(FacesContext facesContext, java.lang.Object state)
          Invoked in the "restore view" phase, this initialises this object's members from the values saved previously into the provided state object.
 java.lang.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(java.lang.String converterMessage)
          Sets Text of the converter message.
 void setImmediate(boolean immediate)
          Sets A boolean value that identifies the phase during which action events should fire.
 void setLocalValueSet(boolean localValueSet)
          Sets whether a local value is currently set.
 void setRequired(boolean required)
          Sets A boolean value that indicates whether a value is required.
 void setRequiredMessage(java.lang.String requiredMessage)
          Sets Text which will be shown if a required value is not submitted.
 void setSubmittedValue(java.lang.Object submittedValue)
          Sets the current submitted value.
 void setValid(boolean valid)
          Sets whether the component's value is currently valid
 void setValidator(MethodBinding validator)
          Deprecated.  
 void setValidatorMessage(java.lang.String validatorMessage)
          Sets Text which will be shown, if validation fails.
 void setValue(java.lang.Object value)
          Store the specified object as the "local value" of this component.
 void setValueChangeListener(MethodBinding valueChangeListener)
          Deprecated.  
 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, java.lang.Object convertedValue)
           
 
Methods inherited from class javax.faces.component.UIOutput
getConverter, getLocalValue, getValue, setConverter
 
Methods inherited from class javax.faces.component.UIComponentBase
addFacesListener, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, 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, setValueBinding
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getContainerClientId, getValueExpression, setValueExpression
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.faces.component.ValueHolder
getConverter, getLocalValue, getValue, setConverter
 

Field Detail

COMPONENT_FAMILY

public static final java.lang.String COMPONENT_FAMILY
See Also:
Constant Field Values

COMPONENT_TYPE

public static final java.lang.String COMPONENT_TYPE
See Also:
Constant Field Values

CONVERSION_MESSAGE_ID

public static final java.lang.String CONVERSION_MESSAGE_ID
See Also:
Constant Field Values

REQUIRED_MESSAGE_ID

public static final java.lang.String REQUIRED_MESSAGE_ID
See Also:
Constant Field Values

UPDATE_MESSAGE_ID

public static final java.lang.String UPDATE_MESSAGE_ID
See Also:
Constant Field Values
Constructor Detail

UIInput

public UIInput()
Construct an instance of the UIInput.

Method Detail

setValue

public void setValue(java.lang.Object value)
Store the specified object as the "local value" of this component. The value-binding named "value" (if any) is ignored; the object is only stored locally on this component. During the "update model" phase, if there is a value-binding named "value" then this local value will be stored via that value-binding and the "local value" reset to null.

Specified by:
setValue in interface ValueHolder
Overrides:
setValue in class UIOutput
Parameters:
value - the new value value

processDecodes

public void processDecodes(FacesContext context)
Set the "submitted value" of this component from the relevant data in the current servet request object.

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.

Overrides:
processDecodes in class UIComponentBase

processValidators

public void processValidators(FacesContext context)
Overrides:
processValidators in class UIComponentBase

processUpdates

public void processUpdates(FacesContext context)
Description copied from class: UIComponentBase
This isn't an input component, so just pass on the processUpdates call to child components and facets that might be input components.

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.

Overrides:
processUpdates in class UIComponentBase

decode

public void decode(FacesContext context)
Description copied from class: UIComponentBase
Check the submitted form parameters for data associated with this component. This default implementation delegates to this component's renderer if there is one, and otherwise ignores the call.

Overrides:
decode in class UIComponentBase

broadcast

public void broadcast(FacesEvent event)
               throws AbortProcessingException
Description copied from class: UIComponentBase
Invoke any listeners attached to this object which are listening for an event whose type matches the specified event's runtime type.

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.

Overrides:
broadcast in class UIComponentBase
Parameters:
event - must not be null.
Throws:
AbortProcessingException

updateModel

public void updateModel(FacesContext context)

validateValue

protected void validateValue(FacesContext context,
                             java.lang.Object convertedValue)

validate

public void validate(FacesContext context)
Determine whether the new value is valid, and queue a ValueChangeEvent if necessary.

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:


getConvertedValue

protected java.lang.Object getConvertedValue(FacesContext context,
                                             java.lang.Object submittedValue)
Convert the provided object to the desired value.

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:


compareValues

protected boolean compareValues(java.lang.Object previous,
                                java.lang.Object value)

resetValue

public void resetValue()
Since:
1.2

isImmediate

public boolean isImmediate()
Gets A boolean value that identifies the phase during which action events should fire. 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.

Specified by:
isImmediate in interface EditableValueHolder
Returns:
the new immediate value

setImmediate

public void setImmediate(boolean immediate)
Sets A boolean value that identifies the phase during which action events should fire. 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.

Specified by:
setImmediate in interface EditableValueHolder
Parameters:
immediate - the new immediate value

isRequired

public boolean isRequired()
Gets A boolean value that indicates whether a value is required. Default value: false.

Specified by:
isRequired in interface EditableValueHolder
Returns:
the new required value

setRequired

public void setRequired(boolean required)
Sets A boolean value that indicates whether a value is required. Default value: false.

Specified by:
setRequired in interface EditableValueHolder
Parameters:
required - the new required value

getConverterMessage

public java.lang.String getConverterMessage()
Gets Text of the converter message.

Returns:
the new converterMessage value

setConverterMessage

public void setConverterMessage(java.lang.String converterMessage)
Sets Text of the converter message.

Parameters:
converterMessage - the new converterMessage value

getRequiredMessage

public java.lang.String getRequiredMessage()
Gets Text which will be shown if a required value is not submitted.

Returns:
the new requiredMessage value

setRequiredMessage

public void setRequiredMessage(java.lang.String requiredMessage)
Sets Text which will be shown if a required value is not submitted.

Parameters:
requiredMessage - the new requiredMessage value

getValidator

public MethodBinding getValidator()
Deprecated. 

Gets A method which is invoked during the validation phase for this component. It is expected to check the submitted value for this component, and if not acceptable then report a validation error for the component.

Specified by:
getValidator in interface EditableValueHolder
Returns:
the new validator value

setValidator

public void setValidator(MethodBinding validator)
Deprecated. 

Sets A method which is invoked during the validation phase for this component. It is expected to check the submitted value for this component, and if not acceptable then report a validation error for the component.

Specified by:
setValidator in interface EditableValueHolder
Parameters:
validator - the new validator value

addValidator

public void addValidator(Validator validator)
Adds a A method which is invoked during the validation phase for this component. It is expected to check the submitted value for this component, and if not acceptable then report a validation error for the component.

Specified by:
addValidator in interface EditableValueHolder

removeValidator

public void removeValidator(Validator validator)
Removes a A method which is invoked during the validation phase for this component. It is expected to check the submitted value for this component, and if not acceptable then report a validation error for the component.

Specified by:
removeValidator in interface EditableValueHolder

getValidators

public Validator[] getValidators()
Gets all A method which is invoked during the validation phase for this component. It is expected to check the submitted value for this component, and if not acceptable then report a validation error for the component.

Specified by:
getValidators in interface EditableValueHolder

getValidatorMessage

public java.lang.String getValidatorMessage()
Gets Text which will be shown, if validation fails.

Returns:
the new validatorMessage value

setValidatorMessage

public void setValidatorMessage(java.lang.String validatorMessage)
Sets Text which will be shown, if validation fails.

Parameters:
validatorMessage - the new validatorMessage value

getValueChangeListener

public MethodBinding getValueChangeListener()
Deprecated. 

Gets 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. The phase in which this method is invoked can be controlled via the immediate attribute.

Specified by:
getValueChangeListener in interface EditableValueHolder
Returns:
the new valueChangeListener value

setValueChangeListener

public void setValueChangeListener(MethodBinding valueChangeListener)
Deprecated. 

Sets 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. The phase in which this method is invoked can be controlled via the immediate attribute.

Specified by:
setValueChangeListener in interface EditableValueHolder
Parameters:
valueChangeListener - the new valueChangeListener value

isValid

public boolean isValid()
Gets whether the component's value is currently valid

Specified by:
isValid in interface EditableValueHolder
Returns:
the new valid value

setValid

public void setValid(boolean valid)
Sets whether the component's value is currently valid

Specified by:
setValid in interface EditableValueHolder
Parameters:
valid - the new valid value

isLocalValueSet

public boolean isLocalValueSet()
Gets whether a local value is currently set. If false, values are being retrieved from any attached ValueBinding

Specified by:
isLocalValueSet in interface EditableValueHolder
Returns:
the new localValueSet value

setLocalValueSet

public void setLocalValueSet(boolean localValueSet)
Sets whether a local value is currently set. If false, values are being retrieved from any attached ValueBinding

Specified by:
setLocalValueSet in interface EditableValueHolder
Parameters:
localValueSet - the new localValueSet value

getSubmittedValue

public java.lang.Object getSubmittedValue()
Gets the current submitted value. This value, if non-null, is set by the Renderer to store a possibly invalid value for later conversion or redisplay, and has not yet been converted into the proper type for this component instance. This method should only be used by the decode() and validate() method of this component, or its corresponding Renderer; however, user code may manually set it to null to erase any submitted value.

Specified by:
getSubmittedValue in interface EditableValueHolder
Returns:
the new submittedValue value

setSubmittedValue

public void setSubmittedValue(java.lang.Object submittedValue)
Sets the current submitted value. This value, if non-null, is set by the Renderer to store a possibly invalid value for later conversion or redisplay, and has not yet been converted into the proper type for this component instance. This method should only be used by the decode() and validate() method of this component, or its corresponding Renderer; however, user code may manually set it to null to erase any submitted value.

Specified by:
setSubmittedValue in interface EditableValueHolder
Parameters:
submittedValue - the new submittedValue value

addValueChangeListener

public void addValueChangeListener(ValueChangeListener listener)
Adds a valueChange listener.

Specified by:
addValueChangeListener in interface EditableValueHolder
Parameters:
listener - the valueChange listener to add

removeValueChangeListener

public void removeValueChangeListener(ValueChangeListener listener)
Removes a valueChange listener.

Specified by:
removeValueChangeListener in interface EditableValueHolder
Parameters:
listener - the valueChange listener to remove

getValueChangeListeners

public ValueChangeListener[] getValueChangeListeners()
Returns an array of attached valueChange listeners.

Specified by:
getValueChangeListeners in interface EditableValueHolder
Returns:
an array of attached valueChange listeners.

saveState

public java.lang.Object saveState(FacesContext facesContext)
Description copied from class: UIComponentBase
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.

Specified by:
saveState in interface StateHolder
Overrides:
saveState in class UIOutput

restoreState

public void restoreState(FacesContext facesContext,
                         java.lang.Object state)
Description copied from class: UIComponentBase
Invoked in the "restore view" phase, this initialises this object's members from the values saved previously into the provided state object.

Specified by:
restoreState in interface StateHolder
Overrides:
restoreState in class UIOutput
state - is an object previously returned by the saveState method of this class.

getFamily

public java.lang.String getFamily()
Overrides:
getFamily in class UIOutput


Copyright © 2010 Apache Software Foundation. All Rights Reserved.