|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.myfaces.commons.validator.ValidatorBase org.apache.myfaces.commons.validator.AbstractCompareToValidator
@JSFValidator(name="mcv:validateCompareTo", clazz="org.apache.myfaces.commons.validator.CompareToValidator", tagClass="org.apache.myfaces.commons.validator.ValidateCompareToTag", serialuidtag="-8879289182242196266L") public abstract class AbstractCompareToValidator
Validates this component against another component.
Specify the foreign component with the for={foreign-component-id} attribute.
Valid operator attribute values:
If the comparator attribute is specified, the component values are compared using the specified java.util.Comparator object. If no comparator is specified, the component values must implement Comparable and are compared using compareTo(). If either value or foreign value does not implement Comparable and no Comparator is specified, validation always succeeds.
Put this validator on the bottom-most component to insure that the foreign component's value has been converted and validated first.
However, this validator will attempt to convert and validate the foreign component's value if this has not already occurred. This process may not be identical to the standard JSF conversion and validation process.
The validation error message key is currently hardcoded as
"{0} value <{1}> must be {2} {3} value <{4}>"
whereThe alternateOperatorName attribute can specify a custom operator name. For example, use "after" instead of "greater than" when comparing dates. The message attribute can specify an alternate validation error message key. For example, use "{0} must be {2} {3}" to remove values from the message.
Known issues:
Field Summary | |
---|---|
static String |
COMPARE_TO_MESSAGE_ID
The message identifier of the FacesMessage to be created if
the comparison check fails. |
static String |
OPERATOR_EQUALS
|
static String |
OPERATOR_EQUALS_ALT
|
static String |
OPERATOR_EQUALS_ALT2
|
static String |
OPERATOR_GREATER_THAN
|
static String |
OPERATOR_GREATER_THAN_ALT
|
static String |
OPERATOR_GREATER_THAN_OR_EQUALS
|
static String |
OPERATOR_GREATER_THAN_OR_EQUALS_ALT
|
static String |
OPERATOR_LESS_THAN
|
static String |
OPERATOR_LESS_THAN_ALT
|
static String |
OPERATOR_LESS_THAN_OR_EQUALS
|
static String |
OPERATOR_LESS_THAN_OR_EQUALS_ALT
|
static String |
OPERATOR_NOT_EQUALS
|
static String |
OPERATOR_NOT_EQUALS_ALT
|
static String |
VALIDATOR_ID
The standard converter id for this converter. |
Fields inherited from interface javax.faces.validator.Validator |
---|
NOT_IN_RANGE_MESSAGE_ID |
Constructor Summary | |
---|---|
AbstractCompareToValidator()
|
Method Summary | |
---|---|
protected Comparator |
createComparator()
|
abstract String |
getAlternateOperatorName()
custom operator name in error message (ie "after" instead of "greater than" for dates) |
protected String |
getClassCastExceptionMessage(String name,
Class clazz,
Object object)
|
abstract Object |
getComparator()
Value binding for an alternate java.util.Comparator object if component values don't implement Comparable |
abstract String |
getFor()
The JSF id of the component with which to compare values. |
abstract String |
getOperator()
Operator for comparison: equals: eq, ==, =, not equals: ne, !=, greater than: gt, >, less than: lt, <, greater than or equals: ge, >=, less than or equals: le, <= |
protected String |
getOperatorForString(String operatorSpecified)
|
protected String |
nameForOperator(String operator)
|
abstract void |
setAlternateOperatorName(String alternateOperatorName)
|
abstract void |
setComparator(Object comparator)
|
abstract void |
setFor(String string)
|
abstract void |
setOperator(String operator)
|
void |
validate(javax.faces.context.FacesContext facesContext,
javax.faces.component.UIComponent uiComponent,
Object value)
|
protected boolean |
validateOperatorOnComparisonResult(String operator,
int result)
|
Methods inherited from class org.apache.myfaces.commons.validator.ValidatorBase |
---|
getDetailMessage, getFacesContext, getFacesMessage, getMessage, getStringValue, getSummaryMessage, getValueExpression, isTransient, restoreAttachedState, restoreState, saveAttachedState, saveState, setDetailMessage, setMessage, setSummaryMessage, setTransient, setValueExpression |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String VALIDATOR_ID
The standard converter id for this converter.
public static final String COMPARE_TO_MESSAGE_ID
The message identifier of the FacesMessage
to be created if
the comparison check fails.
public static final String OPERATOR_EQUALS
public static final String OPERATOR_NOT_EQUALS
public static final String OPERATOR_GREATER_THAN
public static final String OPERATOR_LESS_THAN
public static final String OPERATOR_GREATER_THAN_OR_EQUALS
public static final String OPERATOR_LESS_THAN_OR_EQUALS
public static final String OPERATOR_EQUALS_ALT
public static final String OPERATOR_NOT_EQUALS_ALT
public static final String OPERATOR_GREATER_THAN_ALT
public static final String OPERATOR_LESS_THAN_ALT
public static final String OPERATOR_GREATER_THAN_OR_EQUALS_ALT
public static final String OPERATOR_LESS_THAN_OR_EQUALS_ALT
public static final String OPERATOR_EQUALS_ALT2
Constructor Detail |
---|
public AbstractCompareToValidator()
Method Detail |
---|
protected String getOperatorForString(String operatorSpecified)
protected String nameForOperator(String operator)
protected boolean validateOperatorOnComparisonResult(String operator, int result)
public void validate(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent uiComponent, Object value) throws javax.faces.validator.ValidatorException
javax.faces.validator.ValidatorException
protected String getClassCastExceptionMessage(String name, Class clazz, Object object)
protected Comparator createComparator()
@JSFProperty public abstract String getFor()
public abstract void setFor(String string)
string
- the foreign component_id, on which a value should be validated@JSFProperty public abstract String getOperator()
public abstract void setOperator(String operator)
@JSFProperty public abstract Object getComparator()
public abstract void setComparator(Object comparator)
@JSFProperty public abstract String getAlternateOperatorName()
public abstract void setAlternateOperatorName(String alternateOperatorName)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |