File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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
jQuery in Action, 3rd edition