Top Description Fields Constructors Methods
javax.faces.validator

public Class MethodExpressionValidator

extends Object
implements Validator, StateHolder
Class Inheritance
All Implemented Interfaces
javax.faces.component.StateHolder, javax.faces.validator.Validator, java.util.EventListener
Imports
java.util.Map, javax.el.ELContext, .ELException, .MethodExpression, javax.faces.component.StateHolder, .UIComponent, javax.faces.context.ExternalContext, .FacesContext

MethodExpressionValidator is a Validator that wraps a MethodExpression, and it performs validation by executing a method on an object identified by the MethodExpression.

Field Summary

Modifier and TypeField and Description
private static final String
private MethodExpression
private boolean
private static final String
private Boolean

Constructor Summary

AccessConstructor and Description
public
public
MethodExpressionValidator(MethodExpression
the expression to wrap
methodExpression
)

Construct a Validator that contains a MethodExpression.

Method Summary

Modifier and TypeMethod and Description
private boolean
public boolean
isTransient()

Implements javax.faces.component.StateHolder.isTransient.

If true, the Object implementing this interface must not participate in state saving or restoring.

public void
restoreState(FacesContext
the Faces context.
context
,
Object
the state.
state
)

Implements javax.faces.component.StateHolder.restoreState.

Perform any processing required to restore the state from the entries in the state Object.

public Object
saveState(FacesContext
the Faces context.
context
)

Implements javax.faces.component.StateHolder.saveState.

Gets the state of the instance as a Serializable Object.

public void
setTransient(boolean
boolean pass true if this Object will not participate in state saving or restoring, otherwise pass false.
transientValue
)

Implements javax.faces.component.StateHolder.setTransient.

Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.

public void
validate(FacesContext
FacesContext for the request we are processing
context
,
UIComponent
UIComponent we are checking for correctness
component
,
Object
the value to validate
value
)

Implements javax.faces.validator.Validator.validate.

Perform the correctness checks implemented by this Validator against the specified UIComponent.

private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BEANS_VALIDATION_AVAILABLEback to summary
private static final String BEANS_VALIDATION_AVAILABLE
methodExpressionback to summary
private MethodExpression methodExpression
transientValueback to summary
private boolean transientValue
VALIDATE_EMPTY_FIELDS_PARAM_NAMEback to summary
private static final String VALIDATE_EMPTY_FIELDS_PARAM_NAME
validateEmptyFieldsback to summary
private Boolean validateEmptyFields

Constructor Detail

MethodExpressionValidatorback to summary
public MethodExpressionValidator()
MethodExpressionValidatorback to summary
public MethodExpressionValidator(MethodExpression methodExpression)

Construct a Validator that contains a MethodExpression.

Parameters
methodExpression:MethodExpression

the expression to wrap

Method Detail

isBeansValidationAvailableback to summary
private boolean isBeansValidationAvailable(FacesContext context)
isTransientback to summary
public boolean isTransient()

Implements javax.faces.component.StateHolder.isTransient.

Doc from javax.faces.component.StateHolder.isTransient.

If true, the Object implementing this interface must not participate in state saving or restoring.

Returns:boolean

true if transient, false otherwise.

Annotations
@Override
restoreStateback to summary
public void restoreState(FacesContext context, Object state)

Implements javax.faces.component.StateHolder.restoreState.

Doc from javax.faces.component.StateHolder.restoreState.

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 restoreState method on all those instances as well.

If the state argument is null, take no action and return.

Parameters
context:FacesContext

the Faces context.

state:Object

the state.

Annotations
@Override
saveStateback to summary
public Object saveState(FacesContext context)

Implements javax.faces.component.StateHolder.saveState.

Doc from javax.faces.component.StateHolder.saveState.

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 saveState method on all those instances as well. This method must not save the state of children and facets. That is done via the javax.faces.application.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

Parameters
context:FacesContext

the Faces context.

Returns:Object

the saved state.

Annotations
@Override
setTransientback to summary
public void setTransient(boolean transientValue)

Implements javax.faces.component.StateHolder.setTransient.

Doc from javax.faces.component.StateHolder.setTransient.

Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.

Parameters
transientValue:boolean

boolean pass true if this Object will not participate in state saving or restoring, otherwise pass false.

Annotations
@Override
validateback to summary
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException

Implements javax.faces.validator.Validator.validate.

Doc from javax.faces.validator.Validator.validate.

Perform the correctness checks implemented by this Validator against the specified UIComponent. If any violations are found, a ValidatorException will be thrown containing the javax.faces.application.FacesMessage describing the failure.

For a validator to be fully compliant with Version 2 and later of the specification, it must not fail validation on null or empty values unless it is specifically intended to address null or empty values. An application-wide <context-param> is provided to allow validators designed for JSF 1.2 to work with JSF 2 and later. The javax.faces.VALIDATE_EMPTY_FIELDS <context-param> must be set to false to enable this backwards compatibility behavior.

Parameters
context:FacesContext

FacesContext for the request we are processing

component:UIComponent

UIComponent we are checking for correctness

value:Object

the value to validate

Annotations
@Override
Exceptions
ValidatorException:
if validation fails
NullPointerException:
if context or component is null
validateEmptyFieldsback to summary
private boolean validateEmptyFields(FacesContext ctx)