01: /* Constraint.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Tue Jun 28 13:42:37 2005, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2005 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: import org.zkoss.zk.ui.WrongValueException;
23:
24: /**
25: * A constraint.
26: * Instead of implementing this interface from scratch,
27: * you may use {@link SimpleConstraint} if applicable.
28: *
29: * <p>To have better responsiveness, you can handle more or all validations
30: * at the client by implementing an additional interface,
31: * {@link ClientConstraint}.
32: *
33: * <p>If you prefer to have a custom way to display
34: * the error message (other than the default error box).
35: * You can also implement {@link CustomConstraint}.
36: * Then, {@link CustomConstraint#showCustomError} is called instead of
37: * showing the default error box.
38: * In addition, {@link ClientConstraint} is ignored in this case,
39: * since all validation will be done at the server.
40: *
41: * @author tomyeh
42: * @see CustomConstraint
43: * @see ClientConstraint
44: */
45: public interface Constraint {
46: /** Verifies whether the value is acceptable.
47: * @param comp the component being validated
48: */
49: public void validate(Component comp, Object value)
50: throws WrongValueException;
51: }
|