struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From otisg <ot...@ureach.com>
Subject Re: Re: Accessing an action directly with req parameter and from a fo rward?
Date Tue, 13 May 2003 18:25:28 GMT
Yes I could, but then I would not be going through the Struts
config any more, breaking the MVC pattern, and coupling
AccountAddSave action to AccountSummary in the Java code itself,
instead of only in Struts config.

Thanks,
Otis





________________________________________________
Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag


---- On Tue, 13 May 2003, Erik Price (eprice@ptc.com) wrote:

> But could you not construct the appropriate URL (as a string)
from your 
> AccountAddSave and just redirect directly to that using 
> response.sendRedirect()?
> 
> 
> Erik
> 
> 
> otisg wrote:
> > Thanks for the reply, but unfortunately this does not solve
the
> > problem.
> > Using redirect="true" means that the request attributes set
by
> > the source attributes to be discarded, so the receiving
action
> > will not be able to get the data that it needs from the
source
> > action.
> > 
> > Thanks,
> > Otis
> > 
> > 
> > 
> > ---- On Tue, 13 May 2003, Bailey, Shane C.
> > (SHANE.C.BAILEY@saic.com) wrote:
> > 
> > 
> >>Can you just do this:
> >>
> >><forward name="success" path="/AccountSummary.do"
> > 
> > redirect="true" />
> > 
> >>
> >>
> >>-----Original Message-----
> >>From: otisg [mailto:otisg@ureach.com] 
> >>Sent: Tuesday, May 13, 2003 1:18 PM
> >>To: struts-user@jakarta.apache.org
> >>Subject: Accessing an action directly with req parameter
and
> > 
> > from a forward?
> > 
> >>Hello,
> >>
> >>I am facing a problem that sounds like it would be common,
but
> > 
> > I
> > 
> >>can't find any solutions.  A few other colleagues need to
> > 
> > solve
> > 
> >>the same problem, too.
> >>
> >>Consider 3 actions:
> >>  AccountAddEntry
> >>  AccountAddSave
> >>  AccountSummary
> >>
> >>AccountAddEntry displays a blank 'Account Add' form.
> >>AccountAddSave saves the filled up 'Account Add' form.
> >>
> >>AccountSummary has two modes of operation:
> >>  1. It can be called directly by the user as 
> >>     .../AccountSummary.do?accountID=777
> >>  2. It can be forwarded to by AccountAddSave action, after

> >>     AccountAddSave is done.
> >>
> >>And that is where the problem appears.
> >>In case 1. there is no problem.  A HREF with a link to
> >>.../AccountSummary.do?accountID=777 works fine.
> >>
> >>However, what about case 2?
> >>While I can configure Actions in Struts config to get
chained,
> > 
> > I
> > 
> >>cannot provide the request parameter needed by
AccountSummary
> >>action.
> >>
> >><action path="/CustomerAccountAddSave"
> >>        type="a.b.AccountAddSaveAction"
> >>  <forward name="success" path="/AccountSummary.do"/>
> >>  <forward name="error"   path="/Error.do"/>
> >></action>
> >>
> >>The above cannot work, because ActionSummary.do also needs
> > 
> > the
> > 
> >>accountID parameter, so it knows which account to show.
> >>
> >>One solution is to have the source Action pass the data to
> > 
> > the
> > 
> >>receiving Action in the HttpRequest, like this, for
example:
> >>
> >>  request.setAttribute("accountID", "777");
> >>
> >>However, that required the receiving Action to look for
both
> >>request parameter and request attribute, like this:
> >>
> >>
> >>String acctSidStr = request.getParameter("accountID");
> >>if (acctIDStr == null)
> >>{
> >>    acctDStr = (String)request.getAttribute("accountID");
> >>}
> >>long acctSid = Long.parseLong(accountIDStr);
> >>
> >>There are 2 problems that:
> >>  1. This is not very elegant, having to check 2 places for
> >>data
> >>  2. Because AccountAddSave 'dispatched' to AccountSummary,
> > 
> > the
> > 
> >>     user will not see .../AccountSummary.do in the URL.
> >>     He will see AccountAddSave.do in the URL, but the
> > 
> > Account
> > 
> >>Summary will be shown.  Hitting reload will re-execute
> >>AccountAddSave, and not AccountSummary, as an average user
> > 
> > would
> > 
> >>think.
> >>
> >>
> >>How do people work around this problem?
> >>
> >>My colleagues here are creating an additional JSP that has
> > 
> > only
> > 
> >>a redirect to the next Action in it.  That way they can
> > 
> > provide
> > 
> >>request parameters to the second method instead of passing
> > 
> > data
> > 
> >>in a request attribute _and_ this way they get
AccountSummary
> > 
> > in
> > 
> >>the URL field in the browser, and a true redirect.
> >>
> >>While this works, it is also ugly, because it introduces
> > 
> > these
> > 
> >>little 'redirect JSPs' which act as a redirect bridge
between
> > 
> > 2
> > 
> >>Actions.
> >>
> >>I would love to find a solution that allows me to do this
> > 
> > using
> > 
> >>only Struts config and Actions.
> >>
> >>Is this possible?
> >>
> >>Thank you,
> >>Otis
> >>
> >>
> >>________________________________________________
> >>Get your own "800" number
> >>Voicemail, fax, email, and a lot more
> >>http://www.ureach.com/reg/tag
> >>
> >>
> > 
> >
---------------------------------------------------------------------
> > 
> >>To unsubscribe, e-mail:
> > 
> > struts-user-unsubscribe@jakarta.apache.org
> > 
> >>For additional commands, e-mail:
> > 
> > struts-user-help@jakarta.apache.org
> > 
> >>
> >
---------------------------------------------------------------------
> > 
> >>To unsubscribe, e-mail:
> > 
> > struts-user-unsubscribe@jakarta.apache.org
> > 
> >>For additional commands, e-mail:
> > 
> > struts-user-help@jakarta.apache.org
> > 
> >>
> >>
> > 
> > 
> > ________________________________________________
> > Get your own "800" number
> > Voicemail, fax, email, and a lot more
> > http://www.ureach.com/reg/tag
> > 
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
struts-user-help@jakarta.apache.org
> > 
> > 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
struts-user-help@jakarta.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message