• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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??
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
gotcha, makes sense thank you
 
please buy this thing and then I get a fat cut of the action:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic