struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Taylor" <rtay...@mulework.com>
Subject RE: [repost] Special view information -> ActionForm or request?
Date Thu, 18 Sep 2003 19:22:26 GMT
> I don't understand this approach.  If you need special info in
> the view you
> first call a SetupAction and then have that action forward to a
> ProcessAction?
Nope. SetupAction forwards to a page; not an action.

> Maybe it does work if
> the form bean is in session scope?
It works if your form bean is in request scope too. I rarely put my
form beans in session scope.

> Also, this sounds like action chaining
> to me, which is not considered a Struts best practice.
No again. This is not chaining actions. I think you misunderstood.
I go from a SetupAction to a page which renders the view. Then,
when a user submits the form for processing it goes to ProcessAction.
Both SetupAction and ProcessAction use the same form. When a validation
error occurs, then the user is forwarded to SetupAction. The form remains
in the request and any special data that needs to be retrieved is populated
in the form by SetupAction and forwarded to the page where the original user
input along with any validation errors are displayed.

robert

> -----Original Message-----
> From: Sgarlata Matt [mailto:sgarlata_matt@bah.com]
> Sent: Thursday, September 18, 2003 2:19 PM
> To: Struts Users Mailing List
> Subject: Re: [repost] Special view information -> ActionForm or request?
>
>
> ----- Original Message -----
> From: "Robert Taylor" <rtaylor@mulework.com>
> To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
> Sent: Thursday, September 18, 2003 2:02 PM
> Subject: RE: [repost] Special view information -> ActionForm or request?
>
>
> > Sorry for jumping in, but I've been lurking on this thread
> > and I use this pattern quite frequently.
> >
> > SetupAction ===> page ===> ProcessAction ===> page
> >
> > I have a dynamic form defined in my struts config file and
> > mapped to both SetupAction and ProcessAction. I don't have
> > to manually create the form because Struts does this for me.
> > Its actually very simple:
> >
> > In SetupAction:
> >
> > ActionForward forward = mapping.findForward("success");
> > DynaBean input = (DynaBean)form;
> > // populate input
> > return forward
> >
> > Upon validation failure, my ProcessAction input attribute is set to the
> > action mapping for SetupAction. I can see how this could be
> seen as a bit
> > of a hack, but its just using the existing framework to meet my
> > requirements.
>
> I don't understand this approach.  If you need special info in
> the view you
> first call a SetupAction and then have that action forward to a
> ProcessAction?  I thought this wouldn't work because the form bean is
> recreated with each pass through the ActionServlet.  Maybe it does work if
> the form bean is in session scope?  Also, this sounds like action chaining
> to me, which is not considered a Struts best practice.
>
> > If the data to display is static I just place it in ServletContext
> > when the application starts up and there is no need to necessarily have
> > a SetupAction.
>
> I think this is a standard approach and that it is considered a
> Struts best
> practice.
>
> > Upon validation, you can simply forward directly to the input page.
> >
> >
> > How is that clumsy? Am I missing something?
> >
> > robert
>
>
> ---------------------------------------------------------------------
> 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