permaculture playing cards*
The moose likes Struts and the fly likes Struts2: change Action-Validation.xml file location?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2: change Action-Validation.xml file location??" Watch "Struts2: change Action-Validation.xml file location??" New topic
Author

Struts2: change Action-Validation.xml file location??

Raymond Holguin
Ranch Hand

Joined: Aug 11, 2009
Posts: 72
just started migrating to Struts2 and the fact that I have to have all my Action-Validation.xml files in the same directory as my Action class is annoying the heck out of me. its so cluttered. is there any way to somehow store those validation files in a separate directory and configure struts to look for them there??
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

They just need to be *deployed* to the package hierarchy, they don't need to be there in your source tree.
Raymond Holguin
Ranch Hand

Joined: Aug 11, 2009
Posts: 72
unfortunately that doesn't seem to be the case. my example

package - example contains TestAction.java and TestAction-Validation.xml (WORKS)

created a new package just for validators so now i have this

example - TestAction.java
example.validators - TestAction-Validation.xml

this does NOT work. based on what ive read they always say that you need to keep the xml and class file in the same directory together...but i was really hoping there was a way around that

P.S.
and when i say it WORKS i mean that the form is validated, NOT WORKING means the validations is completely skipped and form submits unvalidated
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It actually *is* the case. It doesn't make any difference at all where they live on your source tree as long as they're *deployed* in the correct package hierarchy. What you've done in your non-working example does not contradict what I'm saying. For example, a Maven project would keep the validation files in src/main/resources/example/TestAction-validation.xml. It's the deployment and packaging that puts them on the classpath.
Raymond Holguin
Ranch Hand

Joined: Aug 11, 2009
Posts: 72
gotcha, makes sense thank you
 
 
subject: Struts2: change Action-Validation.xml file location??
 
Similar Threads
Struts2 validation
Validation Problem in struts2
Struts2
struts2 action-method-validation.xml not working?
Struts2 & validation [SOLVED]