|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.zul.SimpleConstraint
public class SimpleConstraint
A simple constraint that you could build based the predefined constants.
Depending on the component (such as Intbox and Datebox,
you could combine the flags, such as NO_POSITIVE + NO_ZERO
to accept only negative number.
| Field Summary | |
|---|---|
protected int |
_flags
The constraints. |
static int |
NO_EMPTY
Empty is not allowed. |
static int |
NO_FUTURE
Date in the future is not allowed. |
static int |
NO_NEGATIVE
Negative numbers are not allowed. |
static int |
NO_PAST
Date in the past is not allowed. |
static int |
NO_POSITIVE
Postive numbers are not allowed. |
static int |
NO_TODAY
Today is not allowed. |
static int |
NO_ZERO
Zero numbers are not allowed. |
static int |
STRICT
The value must match inside the data from ListModel only. |
| Constructor Summary | |
|---|---|
SimpleConstraint(int flags)
Constructs a constraint with flags. |
|
SimpleConstraint(int flags,
java.lang.String errmsg)
Constructs a constraint with flags and an error message. |
|
SimpleConstraint(int flags,
java.lang.String regex,
java.lang.String errmsg)
Constructs a constraint combining regular expression. |
|
SimpleConstraint(java.lang.String constraint)
Constructs a constraint with a list of constraints separated by comma. |
|
SimpleConstraint(java.lang.String regex,
java.lang.String errmsg)
Constructs a regular-expression constraint. |
|
| Method Summary | |
|---|---|
java.lang.String |
getClientValidation()
Returns the function name in JavaScript or a Javascript code snippet used to validate the value at the client, or null if no client verification is supported. |
java.lang.String |
getErrorMessage(Component comp)
Returns the error message when the client detects an error, or null if not specified. |
int |
getFlags()
Returns the constraint flags, i.e., a combination of NO_POSITIVE, NO_NEGATIVE, STRICT and others. |
static SimpleConstraint |
getInstance(java.lang.String constraint)
Parses a list of constraints from a string to an integer representing a combination of NO_POSITIVE and other flags. |
boolean |
isClientComplete()
Returns whether the client's validation is complete. |
protected int |
parseConstraint(java.lang.String constraint)
Parses a constraint into an integer value. |
void |
validate(Component comp,
java.lang.Object value)
Verifies whether the value is acceptable. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int NO_POSITIVE
public static final int NO_NEGATIVE
public static final int NO_ZERO
public static final int NO_EMPTY
public static final int STRICT
public static final int NO_FUTURE
public static final int NO_PAST
public static final int NO_TODAY
protected int _flags
NO_POSITIVE and others.
| Constructor Detail |
|---|
public SimpleConstraint(int flags)
flags - a combination of NO_POSITIVE, NO_NEGATIVE,
NO_ZERO, and so on.
public SimpleConstraint(int flags,
java.lang.String errmsg)
flags - a combination of NO_POSITIVE, NO_NEGATIVE,
NO_ZERO, and so on.errmsg - the error message to display. Ignored if null or empty.
public SimpleConstraint(java.lang.String regex,
java.lang.String errmsg)
regex - ignored if null or emptyerrmsg - the error message to display. Ignored if null or empty.
public SimpleConstraint(int flags,
java.lang.String regex,
java.lang.String errmsg)
flags - a combination of NO_POSITIVE, NO_NEGATIVE,
NO_ZERO, and so on.regex - ignored if null or emptyerrmsg - the error message to display. Ignored if null or empty.public SimpleConstraint(java.lang.String constraint)
constraint - a list of constraints separated by comma.
Example: no positive, no zero| Method Detail |
|---|
public static final SimpleConstraint getInstance(java.lang.String constraint)
NO_POSITIVE and other flags.
constraint - a list of constraints separated by comma.
Example: no positive, no zero
protected int parseConstraint(java.lang.String constraint)
throws UiException
NO_POSITIVE.
Deriving classes might override this to provide more constraints.
UiExceptionpublic int getFlags()
NO_POSITIVE, NO_NEGATIVE, STRICT and others.
public void validate(Component comp,
java.lang.Object value)
throws WrongValueException
Constraint
validate in interface Constraintcomp - the component being validated
WrongValueExceptionpublic java.lang.String getClientValidation()
ClientConstraintThere are two formats of the return value:
Format 1:
Syntax: function_name
Example: "zkVld.noEmpty"
What Really Happens:
zkVld.noEmpty('id') is called at the client side
to validate the input, where id is the component's identifier.
Format 2:
Syntax: function_name(arg1, arg2, arg3)
where arg could be #{EL_expression}
Example: "myValid(#{self},#{when},'more')"
What Really Happens:
myValid($e('id'),new Date('2007/06/03'),'more')
is called at the client side
to validate the input, where id is the component's identifier.
getClientValidation in interface ClientConstraintpublic java.lang.String getErrorMessage(Component comp)
ClientConstraintIt is used only if you want to override the default error message
shown by the client. It won't affect the message caused by an exception
thrown by Constraint.validate(org.zkoss.zk.ui.Component, java.lang.Object).
getErrorMessage in interface ClientConstraintpublic boolean isClientComplete()
ClientConstraintClientConstraint.getClientValidation()
return null or not.
isClientComplete in interface ClientConstraint
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||