This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts2 very simple validation doesn't work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 very simple validation doesn Watch "Struts2 very simple validation doesn New topic
Author

Struts2 very simple validation doesn't work

Mike Nason
Greenhorn

Joined: Apr 19, 2006
Posts: 20
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???


Wanna code??
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Is the validation file in the same package as the action?
Mike Nason
Greenhorn

Joined: Apr 19, 2006
Posts: 20
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Apr 19, 2006
Posts: 20
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

Joined: Sep 29, 2008
Posts: 12617

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.)
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Struts2 very simple validation doesn't work
 
It's not a secret anymore!