01: /* ClientConstraint.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Wed Apr 11 18:11:54 2007, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.zul;
20:
21: import org.zkoss.zk.ui.Component;
22:
23: /**
24: * Addition interface implemented with {@link Constraint} to denote
25: * how to validate at the client.
26: *
27: * <p>Note: this interface is ignored if {@link CustomConstraint}
28: * is also implemented, since {@link CustomConstraint} causes
29: * all validations are processed at the server.
30: *
31: * @author tomyeh
32: * @see Constraint
33: * @see CustomConstraint
34: */
35: public interface ClientConstraint {
36: /** Returns the function name in JavaScript or a Javascript code snippet
37: * used to validate the value at the client, or null if no client
38: * verification is supported.
39: *
40: * <p>There are two formats of the return value:
41: *
42: * <p>Format 1:<br/>
43: * Syntax: <i>function_name</i><br/>
44: * Example: "zkVld.noEmpty"<br/>
45: * What Really Happens:<br/>
46: * <code>zkVld.noEmpty('id')</code> is called at the client side
47: * to validate the input, where id is the component's identifier.
48: *
49: * <p>Format 2:<br/>
50: * Syntax: <i>function_name(arg1, arg2, arg3)</i><br/>
51: * where arg could be #{<i>EL_expression</i>}<br/>
52: * Example: "myValid(#{self},#{when},'more')"<br/>
53: * What Really Happens:<br/>
54: * <code>myValid($e('id'),new Date('2007/06/03'),'more')</code>
55: * is called at the client side
56: * to validate the input, where id is the component's identifier.
57: */
58: public String getClientValidation();
59:
60: /** Returns whether the client's validation is complete.
61: * If true, onChange won't be sent immediately (unless onChange is listened).
62: * If false, onChange is always sent no matter {@link #getClientValidation}
63: * return null or not.
64: */
65: public boolean isClientComplete();
66:
67: /** Returns the error message when the client detects an error,
68: * or null if not specified.
69: *
70: * <p>It is used only if you want to override the default error message
71: * shown by the client. It won't affect the message caused by an exception
72: * thrown by {@link Constraint#validate}.
73: */
74: public String getErrorMessage(Component comp);
75: }
|