aspose file tools*
The moose likes Struts and the fly likes Struts Validator With Modules Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Validator With Modules" Watch "Struts Validator With Modules" New topic
Author

Struts Validator With Modules

Chris Elvart
Greenhorn

Joined: Feb 20, 2006
Posts: 9
Does the validator framework work with struts modules?

I am experimenting with struts modules using WSAD 5.1 and struts 1.1 and I can't get it to work and can find no references to this anywhere on the web.

I have a module with a validator plugin set up to load module specific validator-rules.xml and validation.xml files and the log shows they get loaded. My actions map correctly, but if I try to use client side validation my elements manufacture no code regardless of what I do. I can't even get the static javascript to come out.

Also, server side pre-action validator validations are not performed even if I tell it to in my action mapping. I have banged my head against this one for a while and am finally asking for help.

<b>???</b><br/>
How does the jsp tag <html:javascript> know what module's rules to load, or do I need to put all of my validation rules in a single multi-module validation rules file (ick!) ?

Here are the relevant sections from the files...
<br/><br/><b>struts-thingy-config.xml<b><br/>

<br/><br/><b>thingy-validator-rules.xml<b> - contains standard struts rules with no additions.<br/>
<br/><br/><b>thingy-validation.xml<b><br/>


<br/>
<b>As a side question...</b><br/>
You see I have rules specified for both "thingyForm" and "/saveThingyAction". Is this normal? I got this setup working in a default module then moved them. In my "/saveThingy" action mapping I tell it to use "thingyForm" but the validator does not load rules for thingyForm but instead loads them for "/saveThingyAction". This is cool because I can have different rules for different actions that use the same form, but it's not cool because I can't specify one set of validation rules for a form regardless of the action it is going to.

How do people usually use this?

Thanks,
Chris
Chris Elvart
Greenhorn

Joined: Feb 20, 2006
Posts: 9
I kept fiddling with this and tracked it down to a typo in the struts config file. It works just fine once you fix that.
 
 
subject: Struts Validator With Modules