I've had the same requirement a couple of times. The way I've settled on doing it, whether it's the best or not I don't know, is this...
I used client-side scripting to prompt the user whether they want to save or not (just some simple dirty data checking, i.e., any time they press a key I set a JavaScript variable to true, which indicates data has changed). Whether they choose yes or no determines what the target of my form submission is... It would either be something like "ThisFormSave.app" or "ThisFormNoSave.app" (changed dynamically via scripting). In struts-config, I map both of them to the same Action. Then in the Action I do: String path = mapping.getPath(); ...then you see whether path is "/ThisFormSave" or /"ThisFormNoSave". Obviously save if appropriate. I also set a hidden form field that specifies where they are going next, which is what forward to use. That's it. On a couple of pages there are a small, finite number of links, in which case I actually had an Action mapping for each one with a Save and NoSave version, all mapped to the same Action, and I check for the "NoSave" substring. If not present, I do the save. The first approach I think works out better though... A little more client-side scripting, but a less verbose struts-config.xml. Matter of taste either way. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Wed, September 22, 2004 10:03 am, James Mitchell said: > You won't be guaranteed to catch any event like browser close or the user > clicking alternate navigation, bookmarks or even typing in a new url. > > If it were are definite requirement, you could simply attempt to catch > that > even, then prompt the user with something like "Warning - you have unsaved > changes. If you wish to save your changes press ok". > > > -- > James Mitchell > Software Engineer / Open Source Evangelist > EdgeTech, Inc. > 678.910.8017 > AIM: jmitchtx > > ----- Original Message ----- > From: <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, September 22, 2004 9:07 AM > Subject: Need Best Practices Thoughts on Actions > > >> >> >> >> >> >> I've got a requirement where if the user tries to leave a form without >> saving changed data they have the option to save "on the fly" before >> going >> to the link they clicked or go to the link without saving the data. On > the >> "save" option I pass the destination (the name of a forward in the >> SaveAction action tag of strut-config) to the SaveAction which does the >> lookup then forwards to their destination. My problem is how to handle > the >> option of not saving. My thought now is to have a RouterAction class >> that >> takes a request parm and uses it to look up a forward in it's action >> mapping. Is this an good way to handle this or are there better ways? >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]