|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.faces.component.UIComponent | +--javax.faces.component.UIComponentBase | +--javax.faces.component.UIOutput | +--javax.faces.component.UIInput
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
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
.
By default, the rendererType
property must be set to
"Text
". This value can be changed by calling the
setRendererType()
method.
Field Summary | |
static java.lang.String |
COMPONENT_FAMILY
The standard component family for this component. |
static java.lang.String |
COMPONENT_TYPE
The standard component type for this component. |
static java.lang.String |
CONVERSION_MESSAGE_ID
The message identifier of the FacesMessage to be created if
a conversion error occurs, and the ConverterException
does not provide a message. |
static java.lang.String |
REQUIRED_MESSAGE_ID
The message identifier of the FacesMessage to be created if
a required check fails. |
Constructor Summary | |
UIInput()
Create a new UIInput instance with default property
values. |
Method Summary | |
void |
addValidator(javax.faces.validator.Validator validator)
Add a Validator instance to the set associated with
this UIInput . |
void |
addValueChangeListener(javax.faces.event.ValueChangeListener listener)
Add a new ValueChangeListener to the set of listeners
interested in being notified when ValueChangeEvent s occur. |
void |
broadcast(javax.faces.event.FacesEvent event)
In addition to to the default UIComponent.broadcast(javax.faces.event.FacesEvent)
processing, pass the ValueChangeEvent being broadcast to the
method referenced by valueChangeListener (if any). |
protected boolean |
compareValues(java.lang.Object previous,
java.lang.Object value)
Return true if the new value is different from the
previous value. |
void |
decode(javax.faces.context.FacesContext context)
Decode any new state of this UIComponent from the
request contained in the specified FacesContext , and store
this state as needed. |
protected java.lang.Object |
getConvertedValue(javax.faces.context.FacesContext context,
java.lang.Object newSubmittedValue)
Convert the submitted value into a "local value" of the appropriate data type, if necessary. |
java.lang.String |
getFamily()
Return the identifier of the component family to which this component belongs. |
java.lang.Object |
getSubmittedValue()
Return the submittedValue value of this UIInput component. |
javax.faces.el.MethodBinding |
getValidator()
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. |
javax.faces.validator.Validator[] |
getValidators()
Return the set of registered Validator s for this
UIInput instance. |
javax.faces.el.MethodBinding |
getValueChangeListener()
Return a MethodBinding instance
method that will be called during Process Validations
phase of he request processing lifecycle, after any registered
ValueChangeListener s have been notified of a value change. |
javax.faces.event.ValueChangeListener[] |
getValueChangeListeners()
Return the set of registered ValueChangeListener s for this
UIInput instance. |
boolean |
isImmediate()
Return the "immediate" state for this component. |
boolean |
isLocalValueSet()
Return the "local value set" state for this component. |
boolean |
isRequired()
Return the "required field" state for this component. |
boolean |
isValid()
Return a flag indicating whether the local value of this component is valid (no conversion error has occurred). |
void |
processDecodes(javax.faces.context.FacesContext context)
Specialized decode behavior on top of that provided by the superclass. |
void |
processUpdates(javax.faces.context.FacesContext context)
In addition to the standard processUpdates behavior
inherited from UIComponentBase , calls
updateModel() . |
void |
processValidators(javax.faces.context.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() . |
void |
removeValidator(javax.faces.validator.Validator validator)
Remove a Validator instance from the set associated with
this UIInput , if it was previously associated. |
void |
removeValueChangeListener(javax.faces.event.ValueChangeListener listener)
Remove an existing ValueChangeListener (if any) from the
set of listeners interested in being notified when
ValueChangeEvent s occur. |
void |
restoreState(javax.faces.context.FacesContext context,
java.lang.Object state)
Perform any processing required to restore the state from the entries in the state Object. |
java.lang.Object |
saveState(javax.faces.context.FacesContext context)
Gets the state of the instance as a Serializable Object. |
void |
setImmediate(boolean immediate)
Set the "immediate" state for this component. |
void |
setLocalValueSet(boolean localValueSet)
Sets the "local value set" state for this component. |
void |
setRequired(boolean required)
Set the "required field" state for this component. |
void |
setSubmittedValue(java.lang.Object submittedValue)
Set the submittedValue value of this UIInput component. |
void |
setValid(boolean valid)
Set a flag indicating whether the local value of this component is valid (no conversion error has occurred). |
void |
setValidator(javax.faces.el.MethodBinding validatorBinding)
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. |
void |
setValue(java.lang.Object value)
Set the value of this UIComponent (if any). |
void |
setValueChangeListener(javax.faces.el.MethodBinding valueChangeMethod)
Set a MethodBinding instance a
that will be called during Process Validations
phase of he request processing lifecycle, after any registered
ValueChangeListener s have been notified of a value change. |
void |
updateModel(javax.faces.context.FacesContext context)
Perform the following algorithm to update the model data associated with this UIInput , if any, as appropriate. |
void |
validate(javax.faces.context.FacesContext context)
Perform the following algorithm to validate the local value of this UIInput . |
protected void |
validateValue(javax.faces.context.FacesContext context,
java.lang.Object newValue)
Set the "valid" property according to the below algorithm. |
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, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding |
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 |
public static final java.lang.String COMPONENT_TYPE
The standard component type for this component.
public static final java.lang.String COMPONENT_FAMILY
The standard component family for this component.
public static final java.lang.String CONVERSION_MESSAGE_ID
The message identifier of the
FacesMessage
to be created if
a conversion error occurs, and the ConverterException
does not provide a message.
public static final java.lang.String REQUIRED_MESSAGE_ID
The message identifier of the
FacesMessage
to be created if
a required check fails.
Constructor Detail |
public UIInput()
Create a new UIInput
instance with default property
values.
Method Detail |
public java.lang.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.
getFamily
in class UIOutput
public java.lang.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
.
getSubmittedValue
in interface EditableValueHolder
public void setSubmittedValue(java.lang.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
.
setSubmittedValue
in interface EditableValueHolder
submittedValue
- The new submitted valuepublic void setValue(java.lang.Object value)
ValueHolder
Set the value of this UIComponent
(if any).
setValue
in interface ValueHolder
setValue
in class UIOutput
value
- The new local valuepublic boolean isLocalValueSet()
setValue()
automatically reset
this property to true
.
isLocalValueSet
in interface EditableValueHolder
public void setLocalValueSet(boolean localValueSet)
setLocalValueSet
in interface EditableValueHolder
public boolean isRequired()
Return the "required field" state for this component.
isRequired
in interface EditableValueHolder
public boolean isValid()
EditableValueHolder
Return a flag indicating whether the local value of this component is valid (no conversion error has occurred).
isValid
in interface EditableValueHolder
public void setValid(boolean valid)
EditableValueHolder
Set a flag indicating whether the local value of this component is valid (no conversion error has occurred).
setValid
in interface EditableValueHolder
valid
- The new valid flagpublic void setRequired(boolean required)
Set the "required field" state for this component.
setRequired
in interface EditableValueHolder
required
- The new "required field" statepublic boolean isImmediate()
EditableValueHolder
Return the "immediate" state for this component.
isImmediate
in interface EditableValueHolder
public void setImmediate(boolean immediate)
EditableValueHolder
Set the "immediate" state for this component. When
set to true, the component's value will be converted
and validated immediately in the Apply Request Values
phase, and ValueChangeEvent
s will be delivered
in that phase as well. The default value for this
property must be false
.
setImmediate
in interface EditableValueHolder
immediate
- The new "immediate" statepublic javax.faces.el.MethodBinding getValidator()
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.
getValidator
in interface EditableValueHolder
public void setValidator(javax.faces.el.MethodBinding validatorBinding)
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
.
setValidator
in interface EditableValueHolder
validatorBinding
- The new MethodBinding
instancepublic javax.faces.el.MethodBinding getValueChangeListener()
Return a MethodBinding
instance
method that will be called during Process Validations
phase of he request processing lifecycle, after any registered
ValueChangeListener
s have been notified of a value change.
getValueChangeListener
in interface EditableValueHolder
public void setValueChangeListener(javax.faces.el.MethodBinding valueChangeMethod)
Set a MethodBinding
instance a
that will be called during Process Validations
phase of he request processing lifecycle, after any registered
ValueChangeListener
s have been notified of a value change.
setValueChangeListener
in interface EditableValueHolder
valueChangeMethod
- The new method binding instancepublic void processDecodes(javax.faces.context.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()
.
processDecodes
in class UIComponentBase
java.lang.NullPointerException
- if context
is null
public void processValidators(javax.faces.context.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.
processValidators
in class UIComponentBase
java.lang.NullPointerException
- if context
is null
public void processUpdates(javax.faces.context.FacesContext context)
In addition to the standard processUpdates
behavior
inherited from UIComponentBase
, calls
updateModel()
.
If the component is invalid afterwards, calls
FacesContext.renderResponse()
.
If a RuntimeException
is thrown during
update processing, calls FacesContext.renderResponse()
and re-throw the exception.
processUpdates
in class UIComponentBase
java.lang.NullPointerException
- if context
is null
public void decode(javax.faces.context.FacesContext context)
UIComponent
Decode any new state of this UIComponent
from the
request contained in the specified FacesContext
, and store
this state as needed.
During decoding, events may be enqueued for later processing
(by event listeners who have registered an interest), by calling
queueEvent()
.
decode
in class UIComponentBase
java.lang.NullPointerException
- if context
is null
public void broadcast(javax.faces.event.FacesEvent event) throws AbortProcessingException
In addition to to the default UIComponent.broadcast(javax.faces.event.FacesEvent)
processing, pass the ValueChangeEvent
being broadcast to the
method referenced by valueChangeListener
(if any).
broadcast
in class UIComponentBase
event
- FacesEvent
to be broadcast
AbortProcessingException
- Signal the JavaServer Faces
implementation that no further processing on the current event
should be performed
java.lang.IllegalArgumentException
- if the implementation class
of this FacesEvent
is not supported by this component
java.lang.NullPointerException
- if event
is
null
public void updateModel(javax.faces.context.FacesContext context)
Perform the following algorithm to update the model data
associated with this UIInput
, if any, as appropriate.
valid
property of this component is
false
, take no further action.localValueSet
property of this component is
false
, take no further action.ValueBinding
for value
exists,
take no further action.setValue()
method of the ValueBinding
to update the value that the ValueBinding
points at.setValue()
method returns successfully:
setValue()
method call fails:
addMessage()
on the specified FacesContext
instance.valid
property of this UIInput
to false
.
context
- FacesContext
for the request we are processing
java.lang.NullPointerException
- if context
is null
public void validate(javax.faces.context.FacesContext context)
Perform the following algorithm to validate the local value of
this UIInput
.
getSubmittedValue()
.
If this returns null, exit without further processing. (This
indicates that no value was submitted for this component.)getConvertedValue(javax.faces.context.FacesContext, java.lang.Object)
.validateValue(javax.faces.context.FacesContext, java.lang.Object)
.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.
context
- The FacesContext
for the current request
java.lang.NullPointerException
- if context
is nullprotected java.lang.Object getConvertedValue(javax.faces.context.FacesContext context, java.lang.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:
Renderer
is present, call
getConvertedValue()
to convert the submitted
value.Renderer
is present, and the submitted
value is a String, locate a Converter
as follows:
getConverter()
returns a non-null Converter
,
use that instance.value
exists,
call getType()
on it.
null
, assume the output
type is String
and perform no conversion.Application.createConverter(Class)
to locate any registered Converter
capable of
converting data values of the specified type.Converter
instance was located, call its
getAsObject()
method to perform the conversion.
If conversion fails:
addMessage()
method on the
FacesContext
.valid
property
on this component to false
This method can be overridden by subclasses for more specific behavior.
ConverterException
protected void validateValue(javax.faces.context.FacesContext context, java.lang.Object newValue)
Set the "valid" property according to the below algorithm.
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:
addMessage()
method on the FacesContext
instance for the current request.valid
property on this component to
false
.valid
property on this component is still
true
, and the local value is not empty, 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.
protected boolean compareValues(java.lang.Object previous, java.lang.Object value)
Return true
if the new value is different from the
previous value.
previous
- old value of this component (if any)value
- new value of this component (if any)public void addValidator(javax.faces.validator.Validator validator)
Add a Validator
instance to the set associated with
this UIInput
.
addValidator
in interface EditableValueHolder
validator
- The Validator
to add
java.lang.NullPointerException
- if validator
is nullpublic javax.faces.validator.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.
getValidators
in interface EditableValueHolder
public void removeValidator(javax.faces.validator.Validator validator)
Remove a Validator
instance from the set associated with
this UIInput
, if it was previously associated.
Otherwise, do nothing.
removeValidator
in interface EditableValueHolder
validator
- The Validator
to removepublic void addValueChangeListener(javax.faces.event.ValueChangeListener listener)
Add a new ValueChangeListener
to the set of listeners
interested in being notified when ValueChangeEvent
s occur.
addValueChangeListener
in interface EditableValueHolder
listener
- The ValueChangeListener
to be added
java.lang.NullPointerException
- if listener
is null
public javax.faces.event.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.
getValueChangeListeners
in interface EditableValueHolder
public void removeValueChangeListener(javax.faces.event.ValueChangeListener listener)
Remove an existing ValueChangeListener
(if any) from the
set of listeners interested in being notified when
ValueChangeEvent
s occur.
removeValueChangeListener
in interface EditableValueHolder
listener
- The ValueChangeListener
to be removed
java.lang.NullPointerException
- if listener
is null
public java.lang.Object saveState(javax.faces.context.FacesContext context)
StateHolder
Gets the state of the instance as a
Serializable
Object.
If the class that implements this interface has references to
instances that implement StateHolder (such as a
UIComponent
with event handlers, validators, etc.)
this method must call the StateHolder.saveState(javax.faces.context.FacesContext)
method on all those
instances as well. This method must not save the state
of children and facets. That is done via the StateManager
This method must not alter the state of the implementing object. In other words, after executing this code:
Object state = component.saveState(facesContext);
component
should be the same as before executing
it.
The return from this method must be Serializable
saveState
in interface StateHolder
saveState
in class UIOutput
public void restoreState(javax.faces.context.FacesContext context, java.lang.Object state)
StateHolder
Perform any processing required to restore the state from the entries in the state Object.
If the class that implements this interface has references to
instances that also implement StateHolder (such as a
UIComponent
with event handlers, validators, etc.)
this method must call the StateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object)
method on all those
instances as well.
restoreState
in interface StateHolder
restoreState
in class UIOutput
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |