public class UIValidateWholeBean extends UIInput implements PartialStateHolder
Modifier and Type | Field and Description |
---|---|
static String |
FAMILY |
ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE, COMPONENT_FAMILY, COMPONENT_TYPE, CONVERSION_MESSAGE_ID, EMPTY_STRING_AS_NULL_PARAM_NAME, REQUIRED_MESSAGE_ID, UPDATE_MESSAGE_ID, VALIDATE_EMPTY_FIELDS_PARAM_NAME
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 |
---|
UIValidateWholeBean() |
Modifier and Type | Method and Description |
---|---|
void |
addValidator(Validator validator)
|
void |
clearInitialState()
For each of the attached objects on this instance that implement |
void |
encodeBegin(FacesContext context)
If our
rendered property is
true , render the beginning of the current state of this
UIComponent to the response contained in the specified
FacesContext . |
static <C extends UIComponent> |
getClosestParent(UIComponent component,
Class<C> parentType) |
String |
getFamily()
Return the identifier of the component family to which this component belongs. |
Object |
getSubmittedValue()
Return the submittedValue value of this
UIInput component. |
String |
getValidationGroups() |
boolean |
initialStateMarked()
An implementation of |
boolean |
isTransient()
If true, the Object implementing this interface must not
participate in state saving or restoring.
|
void |
markInitialState()
In addition to the actions taken in
UIOutput
when PartialStateHolder.markInitialState() is called,
check if any of the installed Validator s are PartialStateHolders and
if so, call PartialStateHolder.markInitialState()
as appropriate. |
void |
restoreState(FacesContext context,
Object state)
Perform any
processing required to restore the state from the entries in the
state Object.
|
Object |
saveState(FacesContext context)
Gets the state of the instance as a
Serializable Object. |
void |
setConverter(Converter converter)
Set the
Converter (if any) that is registered for this
UIComponent . |
void |
setTransient(boolean transientValue)
Denotes
whether or not the Object implementing this interface must or
must not participate in state saving or restoring.
|
void |
setValidationGroups(String validationGroups) |
void |
updateModel(FacesContext context)
Perform
the following algorithm to update the model data
associated with this
UIInput , if any, as appropriate. |
void |
validate(FacesContext context)
Perform the following algorithm to
validate the local value of this
UIInput . |
addValueChangeListener, compareValues, decode, getConvertedValue, getConverterMessage, getRequiredMessage, getValidator, getValidatorMessage, getValidators, getValue, getValueChangeListener, getValueChangeListeners, isEmpty, isImmediate, isLocalValueSet, isRequired, isValid, processDecodes, processUpdates, processValidators, removeValidator, removeValueChangeListener, resetValue, setConverterMessage, setImmediate, setLocalValueSet, setRequired, setRequiredMessage, setSubmittedValue, setValid, setValidator, setValidatorMessage, setValue, setValueChangeListener, validateValue
getConverter, getLocalValue
addClientBehavior, addFacesListener, broadcast, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setValueBinding, subscribeToEvent, unsubscribeFromEvent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, visitTree
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConverter, getLocalValue
public static final String FAMILY
public 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. Note this method should NOT return null
public Object getSubmittedValue()
UIInput
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
getSubmittedValue
in class UIInput
public void setConverter(Converter converter)
ValueHolder
Set the Converter
(if any) that is registered for this
UIComponent
.
setConverter
in interface ValueHolder
setConverter
in class UIOutput
converter
- New Converter
(or null
)public final void addValidator(Validator validator)
UIInput
addValidator
in interface EditableValueHolder
addValidator
in class UIInput
validator
- The Validator
to addpublic void setValidationGroups(String validationGroups)
public String getValidationGroups()
public void validate(FacesContext context)
UIInput
Perform the following algorithm to
validate the local value of this UIInput
.
UIInput.getSubmittedValue()
.
If this returns null
, and
the value of the UIInput.ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE
context-param is true (ignoring case), examine the value of the "required"
property. If the value of "required" is true, continue as below. If
the value of "required" is false or the required attribute is not set,
exit without further processing. If the context-param is not set, or is
set to false (ignoring case), exit without further processing.
(This indicates that no value was submitted for this
component.)javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL
context parameter value is true
(ignoring case), and
getSubmittedValue()
returns a zero-length
String
call UIInput.setSubmittedValue(java.lang.Object)
,
passing null
as the argument and continue processing
using null
as the current submitted
value.UIInput.getConvertedValue(javax.faces.context.FacesContext, java.lang.Object)
.addMessage()
method on the
FacesContext
.valid
property
on this component to false
UIInput.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
with a call to UIInput.setSubmittedValue(java.lang.Object)
passing null
as the argument.
If the local value is different from the previous value of this
component, as determined by a
call to UIInput.compareValues(java.lang.Object, java.lang.Object)
, 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.
validate
in class UIInput
context
- The FacesContext
for the current requestpublic void updateModel(FacesContext context)
UIInput
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.ValueExpression
for value
exists,
take no further action.setValue()
method of the ValueExpression
to update the value that the ValueExpression
points at.setValue()
method returns successfully:
setValue()
method throws an Exception:
FacesMessage
with the id UIInput.UPDATE_MESSAGE_ID
. Create a
UpdateModelException
, passing the FacesMessage
and
the caught exception to the constructor. Create an
ExceptionQueuedEventContext
, passing the FacesContext
,
the UpdateModelException
, this component instance, and
PhaseId.UPDATE_MODEL_VALUES
to its constructor. Call
FacesContext.getExceptionHandler()
and then call
ExceptionHandler.processEvent(javax.faces.event.SystemEvent)
, passing the
ExceptionQueuedEventContext
.
valid
property of this UIInput
to false
.updateModel
in class UIInput
context
- FacesContext
for the request we are processingpublic void encodeBegin(FacesContext context) throws IOException
UIComponent
If our rendered
property is
true
, render the beginning of the current state of this
UIComponent
to the response contained in the specified
FacesContext
. Call
UIComponent.pushComponentToEL(javax.faces.context.FacesContext,javax.faces.component.UIComponent)
.
Call Application.publishEvent(javax.faces.context.FacesContext, java.lang.Class<? extends javax.faces.event.SystemEvent>, java.lang.Object)
, passing
PreRenderComponentEvent
.class
as the first
argument and the component instance to be rendered as the second argument.
If a Renderer
is associated with this UIComponent
, the actual
encoding will be delegated to
Renderer.encodeBegin(FacesContext, UIComponent)
.
If our rendered
property is false
, call
UIComponent.pushComponentToEL(javax.faces.context.FacesContext,javax.faces.component.UIComponent)
and return immediately.
encodeBegin
in class UIComponentBase
context
- FacesContext
for the response we are creatingIOException
- if an input/output error occurs while renderingpublic static <C extends UIComponent> C getClosestParent(UIComponent component, Class<C> parentType)
public void markInitialState()
UIInput
In addition to the actions taken in UIOutput
when PartialStateHolder.markInitialState()
is called,
check if any of the installed Validator
s are PartialStateHolders and
if so, call PartialStateHolder.markInitialState()
as appropriate.
markInitialState
in interface PartialStateHolder
markInitialState
in class UIInput
public boolean initialStateMarked()
UIComponent
An implementation of PartialStateHolder.initialStateMarked()
, this method is
called by the runtime to test if the PartialStateHolder.markInitialState()
method was called.
initialStateMarked
in interface PartialStateHolder
initialStateMarked
in class UIComponent
true
if the initial state is marked, false
otherwise.public void clearInitialState()
UIComponentBase
For each of the attached objects on this instance that implement PartialStateHolder
,
call PartialStateHolder.clearInitialState()
on the attached object.
clearInitialState
in interface PartialStateHolder
clearInitialState
in class UIInput
public boolean isTransient()
StateHolder
If true, the Object implementing this interface must not participate in state saving or restoring.
isTransient
in interface StateHolder
isTransient
in class UIComponentBase
true
if transient, false
otherwise.public void setTransient(boolean transientValue)
StateHolder
Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.
setTransient
in interface StateHolder
setTransient
in class UIComponentBase
transientValue
- boolean pass true
if this
Object will not
participate in state saving or restoring, otherwise pass
false
.public Object saveState(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 UIInput
context
- the Faces context.public void restoreState(FacesContext context, 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.
If the state
argument is null
, take no action and return.
restoreState
in interface StateHolder
restoreState
in class UIInput
context
- the Faces context.state
- the state.Comments to: faces-dev@eclipse.org.
Copyright © 2019 Eclipse Foundation. All rights reserved.
Use is subject to license terms.