|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.faces.validator Interface Validator
- All Superinterfaces:
- EventListener
- All Known Implementing Classes:
- DoubleRangeValidator, LengthValidator, LongRangeValidator, MethodExpressionValidator
public interface Validator
- extends EventListener
Validator 实现是可以对 javax.faces.component.EditableValueHolder
执行验证(正确性检查)的类。视图中的每个 javax.faces.component.EditableValueHolder
可以关联 0 个或多个 Validator
,并在请求处理生命周期的处理验证 阶段调用这些验证器。
各个 Validator
应检查传递给它的值和组件,并抛出包含 javax.faces.application.FacesMessage
的 ValidatorException
,同时记录任何不符合必要规则的失败情况。
为了实现最大的普遍性,应该可以根据 Validator
实现类的属性配置 Validator
实例。例如,范围检查 Validator
应支持配置要使用的最小值和最大值。
Validator
实现必须提供一个公共的无参构造方法。此外,如果 Validator
类希望与视图一同保存和恢复配置的属性值,则该实现还必须实现 StateHolder
。
A Validator implementation is a class that can
perform validation (correctness checks) on a EditableValueHolder
. Zero or more
Validator
s can be associated with each
EditableValueHolder
in
the view, and are called during the Process Validations
phase of the request processing lifecycle.
Individual Validator
s should examine the value and
component that they are passed, and throw a ValidatorException
containing a FacesMessage
, documenting
any failures to conform to the required rules.
For maximum generality, Validator
instances may be
configurable based on properties of the Validator
implementation
class. For example, a range check Validator
might support
configuration of the minimum and maximum values to be used.
Validator
implementations must have a zero-arguments
public constructor. In addition, if the Validator
class
wishes to have configuration property values saved and restored with
the view, the implementation must also implement StateHolder
.
Field Summary | |
---|---|
static String |
NOT_IN_RANGE_MESSAGE_ID
Deprecated. Use DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID or
LongRangeValidator.NOT_IN_RANGE_MESSAGE_ID instead. |
Method Summary | |
---|---|
void |
validate(FacesContext context,
UIComponent component,
Object value)
Perform the correctness checks implemented by this Validator against the specified UIComponent . |
Field Detail |
---|
英文文档:
NOT_IN_RANGE_MESSAGE_ID
static final String NOT_IN_RANGE_MESSAGE_ID
- Deprecated. Use
DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID
orLongRangeValidator.NOT_IN_RANGE_MESSAGE_ID
instead. The message identifier of the
FacesMessage
to be created if the maximum or minimum value check fails, and both the maximum and minimum values for this validator have been set. The message format string for this message may optionally include a{0}
placeholder, which will be replaced by the configured minimum value, and a{1}
placeholder, which will be replaced by the configured maximum value.- See Also:
- Constant Field Values
Method Detail |
---|
public void
validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
根据指定的 UIComponent
执行此 Validator
实现的正确性检查。如果发现任何违规情况,将抛出包含描述该失败的 javax.faces.application.FacesMessage
的 ValidatorException
。
context | 要处理的请求的 FacesContext |
component | 要检查正确性的 UIComponent |
value | 要验证的值 |
Throws | ValidatorException: 如果验证失败 |
Throws | NullPointerException:
如果 context 或 component 为 null |
validate
void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
Perform the correctness checks implemented by this
Validator
against the specifiedUIComponent
. If any violations are found, aValidatorException
will be thrown containing theFacesMessage
describing the failure.- Parameters:
context
- FacesContext for the request we are processingcomponent
- UIComponent we are checking for correctnessvalue
- the value to validate- Throws:
ValidatorException
- if validation failsNullPointerException
- ifcontext
orcomponent
isnull
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!