This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 very simple validation doesn't work

 
Mike Nason
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • 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???
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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
  • 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
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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
  • 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
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic