From: "Alexis HAUMONT" <[EMAIL PROTECTED]>

> Hi all,
....
> I finally code a quick and dirty method in my 'Mother of all' Action to
> allow forward redirects :

... Thanks Alexis.. I had done something similar to that, but I think your
way is prettier.

> PS :
> I think this kind of fonctionality should be Struts-native, no ?
> Or maybe we're the only one doing redirects here ?

I agree.. this comment is also in response to Arik's suggestion to use a
forward.  I'm using a redirect in this case for design reasons.  Here's an
example : let's say I have a main menu..

mainMenuAction --fwd-> mainMenu.jsp

>From there a user clicks "Edit Entry" to edit a specific entry in the
database.

editEntryAction --fwd-> editEntry.jsp

Then the user clicks SAVE..

editEntry.jsp --(new request)--> saveEntryAction

The entry is saved.  So now, return to the main menu.

saveEntryAction -??-> mainMenuAction

But now what?  I want the user to return to the Main Menu.  I don't want to
forward a few reasons.  1) that save is still in the URL, but the user would
be at the main menu.  If s/he bookmarks or hits refresh, the save will occur
again.  I'd like the URL to reflect what page the user is on.  2) It's less
elegant.  The original idea behind fowards was to transfer control from a
Controller to a View.  In the case of saveEntryAction, the Controller has no
view, so I want to redirect to one that does (MainMenu). 3) When the save is
complete, the workflow is complete.  By using a redirect, the request scope
is cleared, and a new workflow can begin at the main menu.

I'm guessing that because redirects aren't so popular in struts that the
commiters have a different approach toward design (?)  I'd like to know how
most people handle situations like the one above.

If you've gotten here, thanks for reading all of this  :)
-Roy


>
> > -----Message d'origine-----
> > De : Arik Levin ( Tikal ) [mailto:[EMAIL PROTECTED]]
> > Envoyé : mardi 11 juin 2002 08:52
> > À : 'Struts Users Mailing List'
> > Objet : RE: Adding query string to redirect w/in an action
> >
> >
> > If you are redirecting from one action to another it's true,
> > I had this problem, you can always use forward ;-)
> >
> > -----Original Message-----
> > From: Roy Truelove [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, June 11, 2002 4:01 AM
> > To: Struts Users Mailing List
> > Subject: Adding query string to redirect w/in an action
> >
> > Hello all,
> >
> > Question about redirects.. I want to redirect from one action
> > to another, but I want to append a query string to the URL.
> > I know how to do this the "dirty" way, by creating a
> > context-relative ActionForward and slapping the queryString
> > onto the end.  What I'm looking for (in theory) is the
> > equivalent to this :
> >
> > myForward = mapping.findForward("toSomeAction");
> > myForward.setRedirect(true);
> > myForward.setQueryString(someJavaUtilMap);
> > return myForward;
> >
> > Is there a clean way to add a query string to a redirect when
> > the redirect goes to an action?
> >
> > Thanks,
> > Roy
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:struts-user-> [EMAIL PROTECTED]>
> > For
> > additional commands,
> > e-mail: <mailto:[EMAIL PROTECTED]>
> >
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to