Boaz

Struts should do its normal stuff when you forward to your SetView action.
That is, it should create the form associated with SetView and populate it
from the request.

If, for example I have a "view customer" action - which gets called with a
"customerNumber" parameter - struts will populate the customerNumber into my
CustomerView form from the request. My action might then retrieve the
customer details from the 'model' using the customerNumber from my form as a
key and then output the full customerDetails to my CustomerView form, then
forward to the appropriate jsp.

If, I also have a "save customer" action - which gets the full set of
customer details from submitting a form -struts will populate the customer
details into my CustomerUpdate form from the request. My action might then
update the customer details in the 'model' using the details from the
CustomerUpdate  form (including the customerNumber from my form as a key).

When I forward from the "save customer" to the "view customer" action, the
customer number is still in the request, so the CustomerView form gets
created, gets populated with my "customerNumber" and does the rest of its
stuff, no problem.

The key to this is that struts will create both forms AND populate both
forms from the request and so both actions should work successfully without
any knowledge of the other Action or its ActionForm. The only link being in
the struts-config.xml where you define your forward from the "Save" action
to the "View" action.

Niall

----- Original Message ----- 
From: "Boaz Barkai" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Sunday, February 29, 2004 12:52 PM
Subject: RE: Forwarding between actions


> The problem is that the forms are different
>
> <action path="/SetEditor" name="editForm" scope="request">
> <forward name="success" path="/editorView.jsp" redirect="false"
> />
> </action>
>
> <action path="/Save" name="viewForm" input="/editorView.jsp"
> scope="request">
> <forward name="success" path="/SetView.do" redirect="true" />
> </action>
>
> but the viewForm is not populated in this iteration
>
> Anyway, thanks for the help
>
>
> -----Original Message-----
> From: Mark Lowe [mailto:[EMAIL PROTECTED]
> Sent: Sunday, February 29, 2004 12:56 PM
> To: Struts Users Mailing List
> Subject: Re: Forwarding between actions
>
>
> So what do your action mappings look like?
>
> <action path="/SetEditor" name="editForm" scope="request">
> <forward name="success" path="/editorView.jsp" redirect="false"
> />
> </action>
>
> <action path="/Save" name="editForm" input="/editorView.jsp"
> scope="request">
> <forward name="success" path="/SetView.do" redirect="true" />
> </action>
>
> If this is the case then you only thing that the actions have to know
> is what's contained in the mappings, which I think is okay because this
> is what mappings are for (at least to my mind).
>
>
>
>
> On 29 Feb 2004, at 11:21, Boaz Barkai wrote:
>
> > Hello
> >
> > I have a case where I wish to forward between actions, like the
> > following flow:
> >
> > SetEditor.do->editorView.jsp -submit-->Save.do->SetView.do
> >
> > Save.do uses a different form bean then SetView so how can I set the
> > SetView.do form bean?
> >
> > I'm trying to keep the actions incapsulated so I do not wish to get
> the
> > form (or add myself) from the environment inside the Save.do action
> > (this is the solution I have - but I don't like it - it means that one
> > action should know about the parameters of another action inside the
> > action code.
> >
> > Thanks
> >
> > Boaz.
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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

Reply via email to