|
||||||||||
| 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 | |
|---|---|
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. |
| Constructor Summary | |
|---|---|
SimpleConstraint(int flags)
|
|
SimpleConstraint(int flags,
java.lang.String errmsg)
Constraints a constraint. |
|
SimpleConstraint(int flags,
java.lang.String regex,
java.lang.String errmsg)
Constructs a constraint combining regular expression. |
|
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(org.zkoss.zk.ui.Component comp)
Returns the error message when the client detects an error, or null if not specified. |
static SimpleConstraint |
getInstance(java.lang.String flags)
Parses flags from a string to an integer representing a combination of NO_POSITIVE and other NO_xxx flags. |
boolean |
isClientComplete()
Returns whether the client's validation is complete. |
void |
validate(org.zkoss.zk.ui.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 NO_FUTURE
public static final int NO_PAST
public static final int NO_TODAY
| Constructor Detail |
|---|
public SimpleConstraint(int flags)
public SimpleConstraint(int flags,
java.lang.String errmsg)
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)
regex - ignored if null or emptyerrmsg - the error message to display. Ignored if null or empty.| Method Detail |
|---|
public static final SimpleConstraint getInstance(java.lang.String flags)
NO_POSITIVE and other NO_xxx flags.
flags - a list of constraint separated by comma.
Example: no positive, no zero
public void validate(org.zkoss.zk.ui.Component comp,
java.lang.Object value)
throws org.zkoss.zk.ui.WrongValueException
Constraint
validate in interface Constraintcomp - the component being validated
org.zkoss.zk.ui.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(org.zkoss.zk.ui.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 | |||||||||