Class ValidateTemplate

  extended by sunlabs.brazil.template.Template
      extended by sunlabs.brazil.sunlabs.ValidateTemplate (view source)
All Implemented Interfaces:

public class ValidateTemplate
extends Template

The ValidateTemplate is designed to validate HTML forms. It performs data validation on sets of properties (e.g. form values) by comparing the values against validation constraints that are specified in other variables.

The "glob" attribute defines the set of variables to be validated, and the "types" attribute maps each variable name matched by "glob" into the variable that names the validation tokens for that variable to be validated. The "types" attribute, which is used to identify the validation types may contain variables of the form, ${n} where 0 < n < 10 which represent the string value matching the nth wildcard in the "glob" attribute.
Example: glob=*.*.*.*.* and types=types.${3}.${1}
will validate a.b.c.d.e against the types contained in types.c.a
The default for types is validate.${1}

For each validate request, all properties matching the specified glob pattern will be validated against pre-loaded validation keys specified by the glob pattern match types. The result will be stored in properties prepended by the prefix attribute, which defaults to the template's prefix.

    <validate glob=pattern [prefix=prepend 
      types=pattern (${1-9}.${1-9})]>

Properties validated by ValidateTemplate

Validation of properties propNames against glob, regular expression, logic/arithmetic expression, max value (integer), max length (string), min value(integer), min length (string) if validation properties exist. If there are n validation properties, then all n are evaulated. A property can fail on multiple validations.

contains the user specified validation key glob pattern to find a space separated list of validation parameters. The typest is built from types and glob
type1 type2 type3 ...
Example: numeric ssn ...
If empty type = propName
contains a glob pattern to match against propName defined in the types list.
contains a regular expression pattern to match against propName defined in the types list.
contains a boolean/arithmetic expression with variable subsititutions to evaluate.
contains the maximum an integer value can have if propName is an integer.
contains the minimum an integer value can have if propName is an integer.
contains the maximum length of a string if propName is a string.
contains the minimum length of a string if propName is a string

Properties set by ValidateTemplate

If validation fails, the error message to be displayed to the user is up to the developer. ValidateTemplate does not store any error messages.
The default for prepend is validate.

contains the number of failed validations.
contains the list of query properties that failed validation along with the type and reason.
Example: propName:type.reason
Variable substitutions of the for ${...} are permitted for the attributes.

Nested Class Summary
static class ValidateTemplate.GlobFormat
          Special version of a format that uses uses the previously defined GlobProperties.
static class ValidateTemplate.GlobProperties
          Special version of a properties that uses the sub expresions of the supplied glob pattern and type to define the keys 1-9.
Field Summary
Fields inherited from class sunlabs.brazil.template.Template
Constructor Summary
Method Summary
 boolean init(RewriteContext hr)
          Called before this template processes any tags.
 void tag_validate(RewriteContext hr)
Methods inherited from class sunlabs.brazil.template.Template
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public ValidateTemplate()
Method Detail


public boolean init(RewriteContext hr)
Description copied from class: Template
Called before this template processes any tags.

Specified by:
init in interface TemplateInterface
init in class Template


public void tag_validate(RewriteContext hr)

Version Kenai-svn-r24, Generated 08/18/09
Copyright (c) 2001-2009, Sun Microsystems.