wood burning stoves 2.0*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem regarding validation " Watch "problem regarding validation " New topic
Author

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" />
</field>
.
.
.
</form>
________________________________________________________


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

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


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.
Thanks,
Naresh
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.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem regarding validation