Constants

 < Day Day Up > 



The Validator Framework allows you to define constants that can be used elsewhere in the file. If you have ever used Jakarta Ant, then using global constants is a lot like using Ant properties (but not exactly). First, you define the constant in the global area as follows:

 <form-validation>     <global>         <constant>             <constant-name>userNameMask</constant-name>             <constant-value>                ^[a–zA–Z]{1}[a–zA–Z0–9_]*$             </constant-value>         </constant>     </global>     ... 

Then you refer to the constant using the ${} syntax, just as you would refer to an Ant property:

    <var>        <var-name>mask</var-name>        <var-value>${userNameMask}</var-value>    </var> 

You can use this constant again and again—for example, you can use it with the userName field on the LoginForm.

Note that you can also define constants inside form sets by using the same constant element structure. This is important because constants might be used only for one locale and form sets can be keyed to a certain local.



 < Day Day Up > 



Professional Jakarta Struts
Professional Jakarta Struts (Programmer to Programmer)
ISBN: 0764544373
EAN: 2147483647
Year: 2003
Pages: 183

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net