Top Description Inners Fields Constructors Methods
com.sun.faces.component.validator

public Class ComponentValidators

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collection, .LinkedList, .List, .Map, .Set, com.sun.faces.facelets.tag.faces.ComponentSupport, com.sun.faces.util.RequestStateManager, jakarta.faces.application.Application, jakarta.faces.component.EditableValueHolder, jakarta.faces.context.FacesContext, jakarta.faces.validator.Validator, jakarta.faces.view.facelets.FaceletContext, .ValidatorHandler

This class is responsible for adding default validators and/or validators that wrap multiple EditableValueHolder instances within the view.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ComponentValidators.ValidatorInfo

Generic information container for a validator at a particular nesting Level.

Field Summary

Modifier and TypeField and Description
private static final String
COMPONENT_VALIDATORS

Key within the FacesContext's attribute map under which a single ComponentValidators instance will be stored.

private LinkedList<ComponentValidators.ValidatorInfo>
validatorStack

Stack of ValidatorInfo instances.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
addDefaultValidatorsToComponent(FacesContext
the FacesContext for the current request
ctx
,
EditableValueHolder
the component receiving the Validators
editableValueHolder
)

Creates and installs default validators, if any, into the argument EditableValueHolder.

public void
addValidators(FacesContext
the FacesContext for the current request
ctx
,
EditableValueHolder
the component receiving the Validators
editableValueHolder
)

Based on the ValidatorInfo instances present on the stack, configure the argument EditableValueHolder with Validators created from the available info.

private static void
addValidatorsToComponent(FacesContext
the FacesContext for the current request
ctx
,
Collection<String>
the validator IDs to be added to the EditableValueHolder
validatorIds
,
EditableValueHolder
the target component to which the validators installed
editableValueHolder
,
LinkedList<ComponentValidators.ValidatorInfo>
current stack of ValidatorInfo instances
validatorStack
)

Install the validators, if not already present on the component, using the IDs included in validatorIds.

public static ComponentValidators

Returns:

a ComponentValidators instance for processing a view request. If createIfNull is false and no ComponentValidators has been created, this method will return null
getValidators
(FacesContext
the FacesContext for the current request
context
,
boolean
flag indicating whether or not a ComponentValidators instance should be created or not
createIfNull
)

public void
popValidatorInfo()

Pops the last ValidatorInfo instance from the stack.

public void
pushValidatorInfo(ComponentValidators.ValidatorInfo
validator info
info
)

Pushes the provided ValidatorInfo onto the stack.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

COMPONENT_VALIDATORSback to summary
private static final String COMPONENT_VALIDATORS

Key within the FacesContext's attribute map under which a single ComponentValidators instance will be stored.

validatorStackback to summary
private LinkedList<ComponentValidators.ValidatorInfo> validatorStack

Stack of ValidatorInfo instances. Each instance represents a particular nesting level within the view. As a nesting level is encountered, a ValidatorInfo will be pushed to the stack and all EditableValueHolder instances will be configured based on all ValidatorInfos on the stack. When the current nesting level is closed, the ValidatorInfo instance will be popped and thus have no impact on other EditableValueHolders.

Constructor Detail

ComponentValidatorsback to summary
public ComponentValidators()

Method Detail

addDefaultValidatorsToComponentback to summary
public static void addDefaultValidatorsToComponent(FacesContext ctx, EditableValueHolder editableValueHolder)

Creates and installs default validators, if any, into the argument EditableValueHolder. This method is merely a utility method to be called when there is no ComponentValidators available, or there are no ValidatorInfo instances on the stack.

Parameters
ctx:FacesContext

the FacesContext for the current request

editableValueHolder:EditableValueHolder

the component receiving the Validators

Annotations
@SuppressWarnings:unchecked
addValidatorsback to summary
public void addValidators(FacesContext ctx, EditableValueHolder editableValueHolder)

Based on the ValidatorInfo instances present on the stack, configure the argument EditableValueHolder with Validators created from the available info.

Parameters
ctx:FacesContext

the FacesContext for the current request

editableValueHolder:EditableValueHolder

the component receiving the Validators

Annotations
@SuppressWarnings:unchecked
addValidatorsToComponentback to summary
private static void addValidatorsToComponent(FacesContext ctx, Collection<String> validatorIds, EditableValueHolder editableValueHolder, LinkedList<ComponentValidators.ValidatorInfo> validatorStack)

Install the validators, if not already present on the component, using the IDs included in validatorIds.

Parameters
ctx:FacesContext

the FacesContext for the current request

validatorIds:Collection<String>

the validator IDs to be added to the EditableValueHolder

editableValueHolder:EditableValueHolder

the target component to which the validators installed

validatorStack:LinkedList<ComponentValidators.ValidatorInfo>

current stack of ValidatorInfo instances

getValidatorsback to summary
public static ComponentValidators getValidators(FacesContext context, boolean createIfNull)
Parameters
context:FacesContext

the FacesContext for the current request

createIfNull:boolean

flag indicating whether or not a ComponentValidators instance should be created or not

Returns:ComponentValidators

a ComponentValidators instance for processing a view request. If createIfNull is false and no ComponentValidators has been created, this method will return null

popValidatorInfoback to summary
public void popValidatorInfo()

Pops the last ValidatorInfo instance from the stack.

pushValidatorInfoback to summary
public void pushValidatorInfo(ComponentValidators.ValidatorInfo info)

Pushes the provided ValidatorInfo onto the stack.

Parameters
info:ComponentValidators.ValidatorInfo

validator info

com.sun.faces.component.validator back to summary

public Class ComponentValidators.ValidatorInfo

extends Object
Class Inheritance
  • java.lang.Object
  • com.sun.faces.component.validator.ComponentValidators.ValidatorInfo

Generic information container for a validator at a particular nesting Level.

Field Summary

Modifier and TypeField and Description
private final FaceletContext
private final boolean
private final ValidatorHandler
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public String
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ctxback to summary
private final FaceletContext ctx
enabledback to summary
private final boolean enabled
ownerback to summary
private final ValidatorHandler owner
validatorIdback to summary
private final String validatorId

Constructor Detail

ValidatorInfoback to summary
public ValidatorInfo(FaceletContext ctx, ValidatorHandler owner)

Method Detail

applyAttributesback to summary
public void applyAttributes(Validator<T> v)
getValidatorIdback to summary
public String getValidatorId()
isEnabledback to summary
public boolean isEnabled()