• 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

Common JSP/Action displaying confirmation details

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks,

I'm in the midst of developing an application which requires the fields of any form to be re-displayed to the user before the actual Action mapping is called. I've not been able to determine a way on how to achieve this feature except for storing the source form object in session.

Has anyone done this before or is there such thing built-in in Struts (don't think so; but worth a try ).

Thanks in advance.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you use the <html:form> tag, the action mapping specified in the "action" attribute will be invoked when the form is submitted. There's no way around this.

You can use javaScript to do all kinds of things before submitting the form, such as popping up an "are you sure?" message, but once the form is submitted, the action mapping is going to be called.

I generally try to resist the urge to question why someone wants to do something, but I'm really having a hard time understanding why this would ever be a requirement. The normal flow of a struts application is to cause execute() method of the Action class to be called when the form is submitted. Once in the Action class, you have a lot of options. You can certainly redisplay the page without saving the data to a database if you want. I just don't see why it would ever be necessary to bypass the Action class.

If you really want to do it, though, you might want to look at putting some logic in the validate() method of your ActionForm to always reject the data the first time and accept it the second time.
 
Michael Lok
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Coming from a financial company, the current internet banking system has the basic feature whereby ALL form submissions are followed by a confirmation page where all user submitted values are re-displayed after validation. This is to protect the user from doing anything odd and to basically cover our tracks; so to speak.

Sometimes there's some processing to be done before displaying the confirmation page e.g. calculating the actual xfer amount having obtained the cross currency rate.

That's the main reason for this feature to be placed in this application.

Anyway, thanks for your input. I'll give some thought to tweaking the validate() function in the form class.
[ January 11, 2006: Message edited by: Michael Lok ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if there is calculation to be done prior to redisplaying the confirmation page, that's all the more reason to do it in the Action class. It's made for that type of thing. As I mentioned, the Action class does not have to save to a database. It can redisplay a confirmation page. I would imagine logic something like this in your execute() method.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic