<filter>
<filter-name>YavTags</filter-name>
<filter-class>net.sf.yavtags.YavFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>YavTags</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
replacing *.do to suit your needs.
<servlet>
<servlet-name>YavServlet</servlet-name>
<servlet-class>net.sf.yavtags.web.YavServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>YavServlet</servlet-name>
<url-pattern>/js/yav.js</url-pattern>
</servlet-mapping>
You can configure YAV-tags and YAV via servlet filter parameters. For example:
<filter>
<filter-name>YavTags</filter-name>
<filter-class>net.sf.yavtags.YavFilter</filter-class>
<init-param>
<param-name>internationalization</param-name>
<param-value>true</param-value>
</init-param>
</filter>
These are all YAV-tags options that you can configure via servlet filter. None of them is mandatory.
<init-param>
<description>
If this param exists, when validation fails it is shown a javascript alert
with this message.
In case you use i18n, use value for i18n key.
</description>
<param-name>additional-error</param-name>
<param-value>yav.additionalError</param-value>
</init-param>
<init-param>
<description>
If it is true, every literal text is treated as a i18n key.
In that case, you have to configure i18n in your application and
provide localized messages for every i18n literal in yav-config.js
(i.e., HEADER_MSG, FOOTER_MSG, DEFAULT_MSG, REQUIRED_MSG, ALPHABETIC_MSG...)
</description>
<param-name>internationalization</param-name>
<param-value>false</param-value>
</init-param>
<!-- YAV configuration options (yav-config.js) with default value. -->
<init-param>
<description>If you want yav to highligh fields with errors</description>
<param-name>inputhighlight</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<description>If you want to use multiple class names</description>
<param-name>multipleclassname</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<description>Classname you want for the error highlighting</description>
<param-name>inputclasserror</param-name>
<param-value>inputError</param-value>
</init-param>
<init-param>
<description>Classname you want for your fields without highlighting</description>
<param-name>inputclassnormal</param-name>
<param-value>inputNormal</param-value>
</init-param>
<init-param>
<description>Classname you want for the inner error highlighting</description>
<param-name>innererror</param-name>
<param-value>innerError</param-value>
</init-param>
<init-param>
<description>Classname you want for the inner help highlighting</description>
<param-name>innerhelp</param-name>
<param-value>innerHelp</param-value>
</init-param>
<init-param>
<description>Div name where errors (and help) will appear (or where jsVar variable is dinamically defined)</description>
<param-name>errorsdiv</param-name>
<param-value>errorsDiv</param-value>
</init-param>
<init-param>
<description>If you want yav to alert you for javascript errors (only for developers)</description>
<param-name>debugmode</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<description>If you want yav to trim the strings</description>
<param-name>trimenabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<description>Decimal separator</description>
<param-name>DECIMAL_SEP</param-name>
<param-value>.</param-value>
</init-param>
<init-param>
<description>Thousands separator</description>
<param-name>THOUSAND_SEP</param-name>
<param-value>,</param-value>
</init-param>
<init-param>
<description>Date format</description>
<param-name>DATE_FORMAT</param-name>
<param-value>MM-dd-yyyy</param-value>
</init-param>
<init-param>
<param-name>alphabetic_regex</param-name>
<param-value>^[A-Za-z]*$</param-value>
</init-param>
<init-param>
<param-name>alphanumeric_regex</param-name>
<param-value>^[A-Za-z0-9]*$</param-value>
</init-param>
<init-param>
<param-name>alnumhyphen_regex</param-name>
<param-value>^[A-Za-z0-9\-_]*$</param-value>
</init-param>
<init-param>
<param-name>alnumhyphenat_regex</param-name>
<param-value>^[A-Za-z0-9\-_@]*$</param-value>
</init-param>
<init-param>
<param-name>alphaspace_regex</param-name>
<param-value>^[A-Za-z0-9\-_ \n\r\t]*$</param-value>
</init-param>
<init-param>
<param-name>email_regex</param-name>
<param-value>^(([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}){0,1}$</param-value>
</init-param>
<init-param>
<description>Change to set your own rule separator</description>
<param-name>RULE_SEP</param-name>
<param-value>|</param-value>
</init-param>
Add the following code to YAV filter configuration in web.xml
<init-param>
<param-name>internationalization</param-name>
<param-value>true</param-value>
</init-param>
Now every literal text is treated as a internationalized key. You have to configure internationalization in
your application and provide localized messages for every i18n literal.
For example, if you have the rule:
<yav:rule value="birthday:yav.birthday|required" />
you'll have to add the following key to your messages bundle:
yav.birthday=Date of birth
Additionally, you have to provide translations for the following default messages:
MANDATORY_MSG=Mandatory field.
DEFAULT_MSG=Data are not valid.
REQUIRED_MSG=The field {1} is required.
ALPHABETIC_MSG=The field {1} is not valid. It must contain only letters.
ALPHANUMERIC_MSG=The field {1} is not valid. It must contain only letters and numbers.
ALNUMHYPHEN_MSG=The field {1} is not valid. It must contain only letters, numbers and hyphens.
ALNUMHYPHENAT_MSG=The field {1} is not valid. It must contain only letters, numbers, hyphens and at sign.
ALPHASPACE_MSG=The field {1} is not valid. It must contain only letters, numbers and spaces.
MINLENGTH_MSG=The field {1} must have at least {2} characters.
MAXLENGTH_MSG=The field {1} must have no more than {2} characters.
NUMRANGE_MSG=The field {1} must be a number in the interval {2}.
DATE_MSG=The field {1} is not a date using format mm-dd-yyyy.
NUMERIC_MSG=The field {1} must be a number.
INTEGER_MSG=The field {1} must be an integer number.
DOUBLE_MSG=The field {1} must be a decimal number.
REGEXP_MSG=The field {1} is not valid. Allowed format is {2}.
EQUAL_MSG=The field {1} must be equal to {2}.
NOTEQUAL_MSG=The field {1} must be not equal to {2}.
DATE_LT_MSG=The field {1} must be before than {2}.
DATE_LE_MSG=The field {1} must be before or equal to {2}.
EMAIL_MSG=The field {1} is not a valid e-mail address.
EMPTY_MSG=The field {1} must be empty.
You can download a complete working example called yavtags-i18n-example.war at the
YAV-tags project download page.
Just deploy it to your Java application server to see it working and to explore source code.