Web site design and hosting - Before the minLength validation rule is called, the
Before the minLength validation rule is called, the required rule will be invoked. You can also set up a rule to depend on multiple rules by separating the rules in the depends attribute with a comma: depends=”required,integer” If a rule that is specified in the depends attribute fails validation, the next rule will not be called. For example, in the minLength validation rule shown previously, the validateMinLength( )method will not be invoked if the required validation rule fails. This should stand to reason, because there’s no sense in checking the length of a value if no value is present. The final attribute supported by the validator element is the jsFunctionName attribute. This optional attribute allows you to specify the name of the JavaScript function. By default, the Validator action name is used. The Validator framework is fairly generic. It contains very basic, atomic rules that can be used by any application. As you’ll see later in this chapter, it’s this generic quality that allows it to be used with non-Struts applications as well. The org.apache.commons.Validator.GenericValidator class implements the generic rules as a set of public static methods. Table 11-1 lists the set of validation rules available in the GenericValidatorclass. Table 11-1. Validation rules in the GenericValidator class Method name Description isBlankOrNullChecks if the field isn’t null and the length of the field is greater than zero, not including whitespace. isByte Checks if the value can safely be converted to a byte primitive. isCreditCard Checks if the field is a valid credit card number. isDate Checks if the field is a valid date. isDouble Checks if the value can safely be converted to a double primitive. isEmail Checks if the field is a valid email address. isFloat Checks if the value can safely be converted to a float primitive. isInRange Checks if the value is within a minimum and maximum range. isInt Checks if the value can safely be converted to an int primitive. isLong Checks if the value can safely be converted to a long primitive. isShort Checks if the value can safely be converted to a short primitive. matchRegexp Checks if the value matches the regular expression. maxLength Checks if the value’s length is less than or equal to the maximum. minLength Checks if the value’s length is greater than or equal to the minimum. Because the validation rules in the GenericValidator are so fine-grained, the Struts developers added a utility class to the Struts framework called org.apache.struts.util.StrutsValidator , which defines a set of higher-level methods that are coupled to the Struts framework but make it easier to use the Validator with Struts.
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.