• 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 Validations problem

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Ranchers,
We are migrating to Struts2 and are planning to use the validator framework for all the client side validations. But I am facing a problem using it.
I have a form which I submit. It goes through the validations configured thru the framework and one of the vaidations failed. I have routed it back to the original jsp on validation fail where I have the fielderror tag on top of the page and the error message is shown successfully. But then all data in the page goes off. As I understand this is because once the validation fails, control just goes back to the jsp without going into my action where I have a method to refetch all the data.
So, instead of routing to the jsp on "input" result, I routed into the data fetcher part of my action. Now the data gets successfully fetched but I find I've lost my error message.
Please help me out with my predicament. Is there any way I can access the field error object so that I can pass that back into the action when I call the data refetcher part?
Thanks in advance.
[ November 03, 2008: Message edited by: John Louis ]
 
Ranch Hand
Posts: 689
Scala Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

First of all for Struts 2 validation your xml name must specify by your Action-validation.xml.

Every field in Xml file must with same jsp field name.

When your validation id done your Action not called so if you get contains data from Action class then make data list to global.

If this is not solve your problem then override validate method.

@Override
public void validate() {
call your method which retrieve your data.
}


Thanks,
Nishan Patel.
 
John Louis
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nishan Patel:
[QB]Hi,

First of all for Struts 2 validation your xml name must specify by your Action-validation.xml.

Every field in Xml file must with same jsp field name.

When your validation id done your Action not called so if you get contains data from Action class then make data list to global.

If this is not solve your problem then override validate method.

@Override
public void validate() {
call your method which retrieve your data.
}



Thanks Nishan... I had found a solution... Am overriding the prepare method now within the action...
 
grapes are vegan food pellets. Eat this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic