You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Yaroslav Novytskyy <sp...@n-ix.com.ua> on 2005/08/01 14:50:11 UTC

(re)populating forms between two actions

Hi!

I use a pattern of PrepareAction-> view.jsp-> SubmitAction and also 
combine those parts to chains like this OnePrepareAction-> oneView.jsp-> 
OneSubmitAction-> TwoPrepareAction-> twoView.jsp-> TwoSubmitAction. All 
actions and views of this chain uses one FormBean which lives in the 
session scope.
As you can see two actions are binded here in a row (OneSubmitAction-> 
TwoPrepareAction) and this place a problem appears: FormBean gets 
populated form the request twice - once before the OneSubmitAction and 
second time before the TwoPrepareAction. So lets imagine, that 
OneSubmitAction submits data to business tear and receives some as an 
responce. OneSubmitAction modifies  FormBean to pass busness' 
modifications to the next Action and ends with a success, which leeds to 
a forward to the "/twoPreapreAction.do". But here FormBean gets 
populated (from the same request) once more and all modifications by 
OneSubmitAction are rewritten.
So people, using the same setup->view->submit style, what is a nice 
solution here?

best regards
Yaroslav

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


Re: (re)populating forms between two actions

Posted by Yaroslav Novytskyy <sp...@n-ix.com.ua>.
Michael Jouravlev wrote:
> On 8/1/05, Yaroslav Novytskyy <sp...@n-ix.com.ua> wrote:
> 
>>Hi!
>>
>>I use a pattern of PrepareAction-> view.jsp-> SubmitAction and also
>>combine those parts to chains like this OnePrepareAction-> oneView.jsp->
>>OneSubmitAction-> TwoPrepareAction-> twoView.jsp-> TwoSubmitAction. All
>>actions and views of this chain uses one FormBean which lives in the
>>session scope.
>>As you can see two actions are binded here in a row (OneSubmitAction->
>>TwoPrepareAction) and this place a problem appears: FormBean gets
>>populated form the request twice - once before the OneSubmitAction and
>>second time before the TwoPrepareAction. So lets imagine, that
>>OneSubmitAction submits data to business tear and receives some as an
>>responce. OneSubmitAction modifies  FormBean to pass busness'
>>modifications to the next Action and ends with a success, which leeds to
>>a forward to the "/twoPreapreAction.do". But here FormBean gets
>>populated (from the same request) once more and all modifications by
>>OneSubmitAction are rewritten.
>>So people, using the same setup->view->submit style, what is a nice
>>solution here?
> 
> 
> 1. Use redirect with no request params.
> 2. Use forwarding, and stick a token into request object, while you in
> the OneSubmitAction. In each setter of your action form you would have
> to check for token.
> 
> http://www.theserverside.com/articles/article.tss?l=StrutsActionMapping
> See "Two actions, one form" chapter.

I've found your article realy clarifying and helpfull epsecially that I 
have found something new for me in it :)
Can you please write how does redirect work and it gives in such a code
<action...>
	...
	<forward .... redirect="true"/>
</action>
I have never used this and never read what is that :(

And one more... You have mentioned "To use form bean as a 
transport/command object ..." So what is the concept of 
"transport/command object"? When I was designing my method (described in 
the begining) I wanted to "pull out" an identifying part of the form 
bean and to make it session scoped or (even better) to make a kind of a 
dialog scope to contain such a identifying info about a currently 
editible item of my hierarchy... would it be a correct way? (a desided 
not to do so at the momemt because of complexity/time frames)

Yaroslav

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

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


Re: (re)populating forms between two actions

Posted by Michael Jouravlev <jm...@gmail.com>.
On 8/1/05, Yaroslav Novytskyy <sp...@n-ix.com.ua> wrote:
> Hi!
> 
> I use a pattern of PrepareAction-> view.jsp-> SubmitAction and also
> combine those parts to chains like this OnePrepareAction-> oneView.jsp->
> OneSubmitAction-> TwoPrepareAction-> twoView.jsp-> TwoSubmitAction. All
> actions and views of this chain uses one FormBean which lives in the
> session scope.
> As you can see two actions are binded here in a row (OneSubmitAction->
> TwoPrepareAction) and this place a problem appears: FormBean gets
> populated form the request twice - once before the OneSubmitAction and
> second time before the TwoPrepareAction. So lets imagine, that
> OneSubmitAction submits data to business tear and receives some as an
> responce. OneSubmitAction modifies  FormBean to pass busness'
> modifications to the next Action and ends with a success, which leeds to
> a forward to the "/twoPreapreAction.do". But here FormBean gets
> populated (from the same request) once more and all modifications by
> OneSubmitAction are rewritten.
> So people, using the same setup->view->submit style, what is a nice
> solution here?

1. Use redirect with no request params.
2. Use forwarding, and stick a token into request object, while you in
the OneSubmitAction. In each setter of your action form you would have
to check for token.

http://www.theserverside.com/articles/article.tss?l=StrutsActionMapping
See "Two actions, one form" chapter.

Michael.

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