You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by bm...@daimlerchrysler.com on 2004/09/22 15:07:21 UTC
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re:[solved] Need Best Practices Thoughts on Actions
Posted by bm...@daimlerchrysler.com.
Thanks to Jim & Frank for your help.
While you guys were responding I ended up using a variation. If they click
save I go ahead and submit the form w/ a hidden field for destination. If
they don't want to save I go to a RouterAction with the destination as a
request parm. The RouterAction then gets the forward mapping passed on the
the request parm.
"Frank W. Zammetti (MLists)" <fz...@omnytex.com> wrote on 09/22/2004
10:12:38 AM:
> 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: <bm...@daimlerchrysler.com>
> > To: <us...@struts.apache.org>
> > 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: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Need Best Practices Thoughts on Actions
Posted by "Frank W. Zammetti (MLists)" <fz...@omnytex.com>.
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: <bm...@daimlerchrysler.com>
> To: <us...@struts.apache.org>
> 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: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Need Best Practices Thoughts on Actions
Posted by James Mitchell <jm...@apache.org>.
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: <bm...@daimlerchrysler.com>
To: <us...@struts.apache.org>
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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org