Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Struts and the fly likes Struts validation does not work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts validation does not work" Watch "Struts validation does not work" New topic
Author

Struts validation does not work

Jerry Wang
Greenhorn

Joined: Aug 04, 2004
Posts: 2
I have defined my form

<form-bean name="registrationForm"
type="org.apache.struts.validator.DynaValidatorActionForm">
..
</form-bean>

And my action definition is

<action path="/register"
type="RegisterAction"
name="registrationForm"
validate="true"
scope="request">
</action>

I already configured the validator plugin in struts-config.xml

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>

And in validation.xml

<form name="/register">
<field property="firstName"
depends="required">
<arg0 key="FirstName" resource="false"/>
</field>
</form>

It seems not working. Because I submit my form with the firstName blank I did not get the error messages as expected. I did put the

<html:errors/>

in my jsp page.

Please help and thanks in advance!
Nimchi Yung
Ranch Hand

Joined: Jan 27, 2004
Posts: 71
Change your validation.xml to



--Nimchi
Jerry Wang
Greenhorn

Joined: Aug 04, 2004
Posts: 2
Originally posted by Nimchi Yung:
Change your validation.xml to



--Nimchi


Thanks Nimchi,

I tried that in the first place and did not work. What other possible ways could make it not work?

Jerry
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Nimchi is correct, though.

Another thing to check is that you are defining firstName in the formbean of struts-config.


A good workman is known by his tools.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts validation does not work
 
Similar Threads
LookupDispatch action with validator
Struts Validator Plug-In Framework
What Are the Causes for Validation Not Doing Anything?
validation
Error while trying NewsLetter Example