org.zkoss.zul
Interface ClientConstraint

All Known Implementing Classes:
SimpleConstraint, SimpleDateConstraint, SimpleSpinnerConstraint

public interface ClientConstraint

Addition interface implemented with Constraint to denote how to validate at the client.

Note: this interface is ignored if CustomConstraint is also implemented, since CustomConstraint causes all validations are processed at the server.

Author:
tomyeh
See Also:
Constraint, CustomConstraint

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.
 boolean isClientComplete()
          Returns whether the client's validation is complete.
 

Method Detail

getClientValidation

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.

There 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.


isClientComplete

boolean isClientComplete()
Returns whether the client's validation is complete. If true, onChange won't be sent immediately (unless onChange is listened). If false, onChange is always sent no matter getClientValidation() return null or not.


getErrorMessage

java.lang.String getErrorMessage(Component comp)
Returns the error message when the client detects an error, or null if not specified.

It 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).



Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo