All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zkoss.zul.ClientConstraint Maven / Gradle / Ivy

There is a newer version: 10.0.0-jakarta
Show newest version
/* ClientConstraint.java

	Purpose:
		
	Description:
		
	History:
		Wed Apr 11 18:11:54     2007, Created by tomyeh

Copyright (C) 2007 Potix Corporation. All Rights Reserved.

{{IS_RIGHT
	This program is distributed under LGPL Version 2.1 in the hope that
	it will be useful, but WITHOUT ANY WARRANTY.
}}IS_RIGHT
*/
package org.zkoss.zul;

/**
 * Addition interface implemented with {@link Constraint} to handle
 * the validation at the client.
 *
 * 

Note: this interface is ignored if {@link CustomConstraint} * is also implemented, since {@link CustomConstraint} causes * all validations are processed at the server. * * @author tomyeh * @see Constraint * @see CustomConstraint */ public interface ClientConstraint { /** Returns the JavaScript snippet that will be evaluated at client * to return a validator, or null if no client constraint is supported. * The validator is later used to validate an input. * *

For example, *

String getClientConstraint() {
	 *  return "new foo.MyValidator()";
	 *}
* *

Instead of return the snippet of JavaScript codes, it can return * an instance of JavaScript string (enclosed with quotation), * if the validator is zul.inp.SimpleConstraint. * *

For example, *

String getClientConstraint() {
	 *  return "'no empty'";
	 *}
* *

The validator could implement the validate, * and showCustomError methods, and an optional property, * serverValidate * methods as follow. validate is required, * while showCustomError and serverValidate are optional. * *

String validate(Widget wgt, String value);
	 *Object showCustomError(Widget wgt, String errmsg);
	 *boolean serverValidate;
* *

Please refer to * zul.inp.SimpleConstraint * for details. * *

Notice that {@link CustomConstraint} has the higher priority than * {@link ClientConstraint}. In other words, {@link ClientConstraint} * is ignored if both defined. * * @return the code snippet that will be evaluated at client to * return a validator. * @since 5.0.0 */ public String getClientConstraint(); /** Returns a list of packages separated by comma that ZK client * engine has to load before evaluating {@link #getClientConstraint}. *

For example, *

com.foo,com.foo.more
* @since 5.0.0 */ public String getClientPackages(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy