Home » Mojarra-2.0.1 » javax » faces » component » [javadoc | source]
javax.faces.component
public class: UIInput [javadoc | source]
java.lang.Object
   javax.faces.component.UIComponent
      javax.faces.component.UIComponentBase
         javax.faces.component.UIOutput
            javax.faces.component.UIInput

All Implemented Interfaces:
    EditableValueHolder, ValueHolder, PartialStateHolder, ComponentSystemEventListener, SystemEventListenerHolder

Direct Known Subclasses:
    HtmlSelectManyCheckbox, UISelectBoolean, UIViewParameter, HtmlSelectOneListbox, HtmlInputSecret, UISelectOne, HtmlSelectOneRadio, HtmlSelectOneMenu, HtmlSelectManyListbox, HtmlInputTextarea, HtmlInputText, UISelectMany, HtmlSelectManyMenu, HtmlInputHidden, HtmlSelectBooleanCheckbox

UIInput is a UIComponent that represents a component that both displays output to the user (like UIOutput components do) and processes request parameters on the subsequent request that need to be decoded. There are no restrictions on the data type of the local value, or the object referenced by the value binding expression (if any); however, individual javax.faces.render.Renderer s will generally impose restrictions on the type of data they know how to display.

During the Apply Request Values phase of the request processing lifecycle, the decoded value of this component, usually but not necessarily a String, must be stored - but not yet converted - using setSubmittedValue(). If the component wishes to indicate that no particular value was submitted, it can either do nothing, or set the submitted value to null.

By default, during the Process Validators phase of the request processing lifecycle, the submitted value will be converted to a typesafe object, and, if validation succeeds, stored as a local value using setValue(). However, if the immediate property is set to true, this processing will occur instead at the end of the Apply Request Values phase.

During the Render Response phase of the request processing lifecycle, conversion for output occurs as for UIOutput .

When the validate() method of this UIInput detects that a value change has actually occurred, and that all validations have been successfully passed, it will queue a ValueChangeEvent . Later on, the broadcast() method will ensure that this event is broadcast to all interested listeners. This event will be delivered by default in the Process Validators phase, but can be delivered instead during Apply Request Values if the immediate property is set to true. If the validation fails, the implementation must call FacesContext#validationFailed .

By default, the rendererType property must be set to "Text". This value can be changed by calling the setRendererType() method.

Nested Class Summary:
enum class  UIInput.PropertyKeys   
Field Summary
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 static final  String CONVERSION_MESSAGE_ID   

The message identifier of the javax.faces.application.FacesMessage to be created if a conversion error occurs, and neither the page author nor the ConverterException provides a message.

 
public static final  String REQUIRED_MESSAGE_ID   

The message identifier of the javax.faces.application.FacesMessage to be created if a required check fails.

 
public static final  String UPDATE_MESSAGE_ID   

The message identifier of the javax.faces.application.FacesMessage to be created if a model update error occurs, and the thrown exception has no message.

 
public static final  String VALIDATE_EMPTY_FIELDS_PARAM_NAME   

The name of an application parameter that indicates how empty values should be handled with respect to validation. See #validateValue for the allowable values and specification of how they should be interpreted.

 
 AttachedObjectListHolder<Validator> validators   

The set of Validator s associated with this UIComponent.

 
Fields inherited from javax.faces.component.UIOutput:
COMPONENT_TYPE,  COMPONENT_FAMILY
Fields inherited from javax.faces.component.UIComponent:
CURRENT_COMPONENT,  CURRENT_COMPOSITE_COMPONENT,  BEANINFO_KEY,  FACETS_KEY,  VIEW_LOCATION_KEY,  COMPOSITE_COMPONENT_TYPE_KEY,  COMPOSITE_FACET_NAME,  attributesThatAreSet,  stateHelper,  compositeParent,  bindings,  initialState,  listenersByEventClass
Constructor:
 public UIInput() 
Method from javax.faces.component.UIInput Summary:
addValidator,   addValueChangeListener,   clearInitialState,   compareValues,   decode,   getConvertedValue,   getConverterMessage,   getFamily,   getRequiredMessage,   getSubmittedValue,   getValidator,   getValidatorMessage,   getValidators,   getValueChangeListener,   getValueChangeListeners,   isEmpty,   isImmediate,   isLocalValueSet,   isRequired,   isValid,   markInitialState,   processDecodes,   processUpdates,   processValidators,   removeValidator,   removeValueChangeListener,   resetValue,   restoreState,   saveState,   setConverterMessage,   setImmediate,   setLocalValueSet,   setRequired,   setRequiredMessage,   setSubmittedValue,   setValid,   setValidator,   setValidatorMessage,   setValue,   setValueChangeListener,   updateModel,   validate,   validateValue
Methods from javax.faces.component.UIOutput:
clearInitialState,   getConverter,   getFamily,   getLocalValue,   getValue,   markInitialState,   restoreState,   saveState,   setConverter,   setValue
Methods from javax.faces.component.UIComponentBase:
addClientBehavior,   addFacesListener,   broadcast,   clearInitialState,   decode,   encodeBegin,   encodeChildren,   encodeEnd,   findComponent,   getAttributes,   getChildCount,   getChildren,   getClientBehaviors,   getClientId,   getDefaultEventName,   getDescriptorMap,   getEventNames,   getFacesContext,   getFacesListeners,   getFacet,   getFacetCount,   getFacets,   getFacetsAndChildren,   getId,   getParent,   getRenderer,   getRendererType,   getRendersChildren,   getValueBinding,   invokeOnComponent,   isRendered,   isTransient,   markInitialState,   processDecodes,   processRestoreState,   processSaveState,   processUpdates,   processValidators,   queueEvent,   removeFacesListener,   restoreAttachedState,   restoreState,   saveAttachedState,   saveState,   setId,   setParent,   setRendered,   setRendererType,   setTransient,   setValueBinding
Methods from javax.faces.component.UIComponent:
addFacesListener,   broadcast,   clearInitialState,   decode,   encodeAll,   encodeBegin,   encodeChildren,   encodeEnd,   findComponent,   getAttributes,   getChildCount,   getChildren,   getClientId,   getClientId,   getCompositeComponentParent,   getContainerClientId,   getCurrentComponent,   getCurrentCompositeComponent,   getFacesContext,   getFacesListeners,   getFacet,   getFacetCount,   getFacets,   getFacetsAndChildren,   getFamily,   getId,   getListenersForEventClass,   getNamingContainer,   getParent,   getRenderer,   getRendererType,   getRendersChildren,   getResourceBundleMap,   getStateHelper,   getStateHelper,   getValueBinding,   getValueExpression,   initialStateMarked,   invokeOnComponent,   isCompositeComponent,   isInView,   isRendered,   isVisitable,   markInitialState,   popComponentFromEL,   processDecodes,   processEvent,   processRestoreState,   processSaveState,   processUpdates,   processValidators,   pushComponentToEL,   queueEvent,   removeFacesListener,   setId,   setInView,   setParent,   setRendered,   setRendererType,   setValueBinding,   setValueExpression,   subscribeToEvent,   unsubscribeFromEvent,   visitTree
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.faces.component.UIInput Detail:
 public  void addValidator(Validator validator) 
 public  void addValueChangeListener(ValueChangeListener listener) 
 public  void clearInitialState() 
 protected boolean compareValues(Object previous,
    Object value) 

    Return true if the new value is different from the previous value.

 public  void decode(FacesContext context) 
 protected Object getConvertedValue(FacesContext context,
    Object newSubmittedValue) throws ConverterException 

    Convert the submitted value into a "local value" of the appropriate data type, if necessary. Employ the following algorithm to do so:

    • If a Renderer is present, call getConvertedValue() to convert the submitted value.
    • If no Renderer is present, and the submitted value is a String, locate a Converter as follows:
      • If getConverter() returns a non-null Converter , use that instance.
      • Otherwise, if a value binding for value exists, call getType() on it.
        • If this call returns null, assume the output type is String and perform no conversion.
        • Otherwise, call Application.createConverter(Class) to locate any registered Converter capable of converting data values of the specified type.
    • If a Converter instance was located, call its getAsObject() method to perform the conversion. If conversion fails:
      • Enqueue an appropriate error message by calling the addMessage() method on the FacesContext.
      • Set the valid property on this component to false
    • Otherwise, use the submitted value without any conversion

    This method can be overridden by subclasses for more specific behavior.

 public String getConverterMessage() 
 public String getFamily() 
 public String getRequiredMessage() 
 public Object getSubmittedValue() 

    Return the submittedValue value of this UIInput component. This method should only be used by the decode() and validate() method of this component, or its corresponding Renderer .

 public MethodBinding getValidator() 
Deprecated! { - @link #getValidators} should be used instead.

    Return a MethodBinding pointing at a method that will be called during Process Validations phase of the request processing lifecycle, to validate the current value of this component.

 public String getValidatorMessage() 
 public Validator[] getValidators() 

    Return the set of registered Validator s for this UIInput instance. If there are no registered validators, a zero-length array is returned.

 public MethodBinding getValueChangeListener() 
 public ValueChangeListener[] getValueChangeListeners() 

    Return the set of registered ValueChangeListener s for this UIInput instance. If there are no registered listeners, a zero-length array is returned.

 public static boolean isEmpty(Object value) 
 public boolean isImmediate() 
 public boolean isLocalValueSet() 
    Return the "local value set" state for this component. Calls to setValue() automatically reset this property to true.
 public boolean isRequired() 

    Return the "required field" state for this component.

 public boolean isValid() 
 public  void markInitialState() 
 public  void processDecodes(FacesContext context) 

    Specialized decode behavior on top of that provided by the superclass. In addition to the standard processDecodes behavior inherited from UIComponentBase , calls validate() if the the immediate property is true; if the component is invalid afterwards or a RuntimeException is thrown, calls FacesContext#renderResponse .

 public  void processUpdates(FacesContext context) 
 public  void processValidators(FacesContext context) 

    In addition to the standard processValidators behavior inherited from UIComponentBase , calls validate() if the immediate property is false (which is the default); if the component is invalid afterwards, calls FacesContext#renderResponse . If a RuntimeException is thrown during validation processing, calls FacesContext#renderResponse and re-throw the exception.

 public  void removeValidator(Validator validator) 

    Remove a Validator instance from the set associated with this UIInput , if it was previously associated. Otherwise, do nothing.

 public  void removeValueChangeListener(ValueChangeListener listener) 
 public  void resetValue() 

    Convenience method to reset this component's value to the un-initialized state. This method does the following:

    Call #setValue passing null.

    Call #setSubmittedValue passing null.

    Call #setLocalValueSet passing false.

    Call #setValid passing true.

    Upon return from this call if the instance had a ValueBinding associated with it for the "value" property, this binding is evaluated when UIOutput#getValue is called. Otherwise, null is returned from getValue().

 public  void restoreState(FacesContext context,
    Object state) 
 public Object saveState(FacesContext context) 
 public  void setConverterMessage(String message) 

    Override any ValueExpression set for the "converterMessage" with the literal argument provided to this method. Subsequent calls to #getConverterMessage will return this value;

 public  void setImmediate(boolean immediate) 
 public  void setLocalValueSet(boolean localValueSet) 
    Sets the "local value set" state for this component.
 public  void setRequired(boolean required) 

    Set the "required field" state for this component.

 public  void setRequiredMessage(String message) 

    Override any ValueExpression set for the "requiredMessage" with the literal argument provided to this method. Subsequent calls to #getRequiredMessage will return this value;

 public  void setSubmittedValue(Object submittedValue) 

    Set the submittedValue value of this UIInput component. This method should only be used by the decode() and validate() method of this component, or its corresponding Renderer .

 public  void setValid(boolean valid) 
 public  void setValidator(MethodBinding validatorBinding) 
Deprecated! Use - #addValidator instead, obtaining the argument Validator by creating an instance of javax.faces.validator.MethodExpressionValidator .

    Set a MethodBinding pointing at a method that will be called during Process Validations phase of the request processing lifecycle, to validate the current value of this component.

    Any method referenced by such an expression must be public, with a return type of void, and accept parameters of type FacesContext , UIComponent , and Object.

 public  void setValidatorMessage(String message) 

    Override any ValueExpression set for the "validatorMessage" with the literal argument provided to this method. Subsequent calls to #getValidatorMessage will return this value;

 public  void setValue(Object value) 
 public  void setValueChangeListener(MethodBinding valueChangeListener) 
Deprecated! Use - #addValueChangeListener instead, obtaining the argument ValueChangeListener by creating an instance of javax.faces.event.MethodExpressionValueChangeListener .

    {@inheritDoc}
 public  void updateModel(FacesContext context) 

    Perform the following algorithm to update the model data associated with this UIInput , if any, as appropriate.

    • If the valid property of this component is false, take no further action.
    • If the localValueSet property of this component is false, take no further action.
    • If no ValueExpression for value exists, take no further action.
    • Call setValue() method of the ValueExpression to update the value that the ValueExpression points at.
    • If the setValue() method returns successfully:
      • Clear the local value of this UIInput .
      • Set the localValueSet property of this UIInput to false.
    • If the setValue() method throws an Exception:
    • The exception must not be re-thrown. This enables tree traversal to continue for this lifecycle phase, as in all the other lifecycle phases.
 public  void validate(FacesContext context) 

    Perform the following algorithm to validate the local value of this UIInput .

    • Retrieve the submitted value with #getSubmittedValue . If this returns null, exit without further processing. (This indicates that no value was submitted for this component.)
    • If the javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL context parameter value is true (ignoring case), and getSubmittedValue() returns a zero-length String call #setSubmittedValue , passing null as the argument and continue processing using null as the current submitted value.
    • Convert the submitted value into a "local value" of the appropriate data type by calling #getConvertedValue .
    • Validate the property by calling #validateValue .
    • If the valid property of this component is still true, retrieve the previous value of the component (with getValue()), store the new local value using setValue(), and reset the submitted value to null. If the local value is different from the previous value of this component, fire a ValueChangeEvent to be broadcast to all interested listeners.

    Application components implementing UIInput that wish to perform validation with logic embedded in the component should perform their own correctness checks, and then call the super.validate() method to perform the standard processing described above.

 protected  void validateValue(FacesContext context,
    Object newValue) 

    Set the "valid" property according to the below algorithm.

    • If the valid property on this component is still true, and the required property is also true, ensure that the local value is not empty (where "empty" is defined as null or a zero-length String). If the local value is empty:

    • Otherwise, if the valid property on this component is still true, take the following action to determine if validation of this component should proceed.

      • If the value is not empty, validation should proceed.

      • If the value is empty, but the system has been directed to validate empty fields, validation should proceed. The implementation must obtain the init parameter Map from the ExternalContext and inspect the value for the key given by the value of the symbolic constant #VALIDATE_EMPTY_FIELDS_PARAM_NAME . If there is no value under that key, use the same key and look in the application map from the ExternalContext. If the value is null or equal to the string “auto” (without the quotes) take appropriate action to determine if Bean Validation is present in the runtime environment. If not, validation should not proceed. If so, validation should proceed. If the value is equal (ignoring case) to “true” (without the quotes) validation should proceed. Otherwise, validation should not proceed.

      • If the above determination indicates that validation should proceed, call the validate() method of each Validator registered for this UIInput , followed by the method pointed at by the validatorBinding property (if any). If any of these validators or the method throws a ValidatorException , catch the exception, add its message (if any) to the FacesContext , and set the valid property of this component to false.