aspose file tools*
The moose likes Struts and the fly likes Struts2 Validations problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 Validations problem" Watch "Struts2 Validations problem" New topic
Author

Struts2 Validations problem

John Louis
Greenhorn

Joined: Aug 14, 2008
Posts: 10
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 ]
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 686

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.


Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
John Louis
Greenhorn

Joined: Aug 14, 2008
Posts: 10
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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 Validations problem