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 ).
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.
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.
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 ]
Joined: Feb 15, 2005
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.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Common JSP/Action displaying confirmation details