• 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

Displaying error in multi page form.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic