struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Alfors" <peter.alf...@hksystems.com>
Subject Re: Can I pass some dynamic parameter via Action class?
Date Tue, 10 Oct 2000 14:42:34 GMT
Hi Jason,

    You are correct.  For most situations, we place parameters in request
attributes.  However, there is an instance in which we chose to use query
strings...

We have a page that is a list of items for the user to choose from.  Each item
consists of a link with a query string that points to an action class
(ActionRow.do?id=1).  The ActionRow class then displays a detail page for the
specified item ID.

In addition, we allow users to add new items.  The 'add' page calls an action
class (ActionAdd.do) to perform the actual addition to the database.  Upon
success, we forward the user to the detail page (ActionRow.do) for the new
item.  Since the ActionRow class is expecting the item ID to be in the query
string (as it is in the list page), we then add the query string to the action
forward before returning from the ActionAdd action class.

Granted, there are other options available to us.  We could have the item
detail action check both the request attribute and the query string.  Or we
could have separate action classes.

I would be interested in hearing other options that may provide a better
solution.  After all, we are always ready to learn something new!

Pete



Jason Kitchen wrote:

> Peter Alfors wrote:
> >
> > Hello Jung,
> >
> > This is one method to add a query string to your action forward.
> >
> >   public ActionForward perform(ActionMapping pMapping,
> >                                 ActionForm pForm,
> >                                 HttpServletRequest pRequest,
> >                                 HttpServletResponse pResponse)
> >      throws IOException, ServletException
> >   {
> >
> >             ... <action class code> ...
> >
> >             ActionForward actionForward = new ActionForward();
> >
> > actionForward.setPath(pMapping.findForward("success").getPath() +
> > "?key1=" + value1);
> >             return actionForward;
> >   }
> >
> > However, there may be a better method out there.
> >
> > Pete
>
> Since the forward is internal to the webserver rather than a redirect there
> doesn't seem to be much point in putting this onto the URL. Why don't you
> just put the parameters directly onto the request ?
>
> request.setAttribute("key1", value1);
> return pMapping.findForward("success");
>
> -- Jason

Mime
View raw message