wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 very simple validation doesn't work
 
Similar Threads
problems validation.xml in struts 2
problems in validation part of struts 2
Pop up error while using validation in struts2.0
Action class not being called after validation
Form Validation using xml in struts2