











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A step-by-step guide on how to configure validation-rules.xml for javascript in struts. It covers the use of custom tags, the process of validating forms in jsp pages, and advanced features such as creating custom validation rules. It also includes examples and best practices.
Typology: Slides
1 / 19
This page cannot be seen from the preview
Don't miss anything!












**
Advanced Features
Create a new validation method
Modify the validation-rules.xml file to rules. xml
contain the new validation method
Modify the validation.xml file to use the new
validation rule rule.
Create a new validation method
public static boolean validateExactLength( Object bean, ValidatorAction va, Field field, ActionErrors errors,
HttpServletRequest request) {
String value = null;
if (isString( bean)) {
value = (String) bean;
} else {
value = ValidatorUtil. getValueAsString( bean, field. getProperty());
String exactLength = field. getVarValue(" exactlength");
if (! GenericValidator. isBlankOrNull( value)) {
try {
int length = Integer. parseInt( exactLength);
if ( value. length() != length ) {
errors. add( field. getKey(), Resources. getActionError( request, va, field));
return false;
} catch (Exception e) { errors. add( field. getKey(), Resources. getActionError( request, va, field));
return false;
} return true;
Modify validation.xml
** exactlength**
** 10 **
** mask**
^[ a- zA- Z]$*
Best Practice Guidelines
Advaced Validation
Techniques
QUIZ