Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Raymond Holguin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gotcha, makes sense thank you
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic