• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Struts2 very simple validation doesn't work

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!
I have very simple validation from tutorial which doesn't work for me.
I have jsp with form (age, name) and want to perform some validation. The problem that my validation is ignored and nothing happens. Please take a look at that and give me some hints

--showMe.jsp--


--ShowMe.java--
Simple action that does nothing

--SaveMe.java--


--struts.xml--


-- SaveMe-validation.xml --


Every time I input any values the message "Saved!" appears, but I want some messages from validator. What is the problem???
 
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
Is the validation file in the same package as the action?
 
Mike Nason
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, the validation file is in the same place (folder, package as action files)
I just don't have any idea of where I am wrong
 
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
I don't see anything off the top of my head--are you sure the validation file is being deployed?

BTW, there's a "key" attribute that wraps up the label/name/value attributes and supports I18N automatically.
 
Mike Nason
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good point!
Thanks!

The problem is that xml files is not included in .war file!
I use Maven2 and didn't do anything special configuration, just point in pom.xml

I should do something to point maven to include xml files as well in final war.
 
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
XML files should be in src/main/resources/{package hierarchy}/filename. They'll be deployed/packaged if they're in there (as will properties files, etc.)
 
It's weird that we cook bacon and bake cookies. Eat this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic