This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes problem regarding validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem regarding validation " Watch "problem regarding validation " New topic

problem regarding validation

Vasudhaiv Naresh
Ranch Hand

Joined: May 13, 2005
Posts: 57
Hi all!
I'm new to Struts. I was trying to implement validations using :
1. validation.xml
2. validation-rules.xml

I've a form bean, named 'userRegistrationForm', declared in the struts-config.xml. This form bean is mapped to the "UserRegistrationForm" which extends the "ValidatorForm" class. I've not defined the validate() method, since its already implemented in the super class(ValidatorForm).
I've set the following in the validation.xml :

<form name="userRegistrationForm">
<field property="firstName" depends="required">
<arg key="userRegistrationForm.firstName" />

Also I've made the necessary plugin declarations required to enable the validation using :

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
value={paths} />

Upon deploying, I found that even when the "first name" field or any other field is left blank, an error message is not being displayed.
Please let me know if I'm wrong or if I'm missing something.
Vasudhaiv Naresh
Ranch Hand

Joined: May 13, 2005
Posts: 57
hi all!

the source for the userRegistration.jsp file is as follows :

When I submit the form, a javascript error saying :
" user_required not found ".
Upon debugging it was found that,
the generated javascript has a function : "userRegistrationForm_required"
upon debugging i found instead of this function, some user_required() is being called, and hence the error.

I agree. Here's the link:
subject: problem regarding validation
Similar Threads
Need step by step procedure to use Validation framework
How to use Validators
Struts validation not displaying error messages
Form validation in struts
Another "Validator Plugin" Problem