This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 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 "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