aspose file tools*
The moose likes Struts and the fly likes Displaying  error in multi page form. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Displaying  error in multi page form." Watch "Displaying  error in multi page form." New topic
Author

Displaying error in multi page form.

Karthik Kumar Somasundaram
Greenhorn

Joined: Aug 30, 2006
Posts: 2
I'm using a form bean, ABCFormBean of type ValidatorForm, in 5 jsp pages. In struts config, i've defined the action tag and its input attribute value = "URL of the first of the JSP pages". I use the validation framework for form validation and the validation errors get displayed in the page specified in the input attribute. So far so good...

But now i want the errors in the 3rd page to be displayed after validation in the 3rd page itself rather than the page specified in the input attribute. Can somebody help me at this seemingly tricky situation?
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
I don't thing what you are looking is possible with Form Validation. Form validation is carried out before the action is called. Struts uses the mapping element to find the page to be redirected if validation fails. One way I think of handling this
- Define/write logic to validate only fields that are required for the current page in action form (it can be as well in action). Don't use the form validation.
- From the action class call the right method for validating the current page form. If the method returns non-empty actionErrors/Messages then find out what page the user is currently in and forward the request to the same page.
Karthik Kumar Somasundaram
Greenhorn

Joined: Aug 30, 2006
Posts: 2
This is not an uncommon issue.. There must be a work around provided in the validation framework. It has been long since we used the validate method of the action class for form validation. Its is not adviced by the architecture we follow in the company. They require the use of validation framework(validation.xml and validation-rules file).

If anybody proficient in the validation framework can help us out, it will be beneficial for many who come across this common problem.
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
Karthik, It's been while from the last update, I am not sure if you were able to find a solution to this problem, I tried few things and found out that this isn't impossible to do. The problem is all the ActionConfig's are frozen and we won't be able to make changes to the action config - meaning it's not directly possible to change the "input" attribute of the action.

There is a work around (comes with maintenance issue) is to create your own extension to ActionServlet class and override init() method. In this method you copy the exact code as in base class except for commenting out the "freeze()" method calls. You need to configure your extension in web.xml

http://www.manfred-wolff.de/data/Configuration.pdf explains in detail how to do this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying error in multi page form.