You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mike Duffy <md...@yahoo.com> on 2006/11/04 18:03:44 UTC

Struts 2.0 Application Lifecycle

I've done a quick scan of the Struts 2.0 documentation.  I did not find a reference to the Struts
2.0 application life cycle.

Does anyone know of a reference that would be similar to the JSF article at the link below?

http://www-128.ibm.com/developerworks/java/library/j-jsf2/

Thx.

Mike


 
____________________________________________________________________________________
Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates 
(http://voice.yahoo.com)


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


Re: Struts 2.0 Application Lifecycle

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Ted Husted on 05/11/06 21:27, wrote:
> On 11/5/06, Adam Hardy <ah...@cyberspaceroad.com> wrote:
>> Imagine a common-place user story where the user sees a list of items, and
>> can choose one item, go to the 'edit item' page, submit changes, and be 
>> returned to the item list.
>> 
>> On the edit submit, my action processes the edit and does a save, and does
>> a Post-Redirect-Get back to the list.
>> 
>> Where do I put the logic fetching the list again? Obviously I don't want it
>> in the edit action. Do I put it in an action of its own, or do I put it in
>> an interceptor or even a PreResultListener?
> 
> Oh, in the normal course, I don't think anything so exotic would be needed.
> :)
> 
> If we are fetching the list from a database, I'd put the actual logic in a
> business facade. A good approach is to use Spring to instantiate the business
> facade and then inject the business object into the Action. Struts 2 can
> "autowire" Action properties from the Spring configuration. If you give the
> Spring bean and the Action property the same name and type, the framework
> will take care of the result.
> 
> * http://jroller.com/page/TedHusted?entry=struts_2_spring_love_fest
> 
> The list can be represented as a property on a base "support" Action that
> other Action classes extend. All any Action needs to do is call the property,
> and, behind the scenese, the property invokes the business facade. The
> business facade itself can be autowired from Spring, so the Action just needs
> to do is get the property name right!
> 
> If retrieving the list requires a key, a common approach is to create a
> profile object that is stored in the session and can be retrieved as a
> property on the base support Action.

You've made 75% of the code from my baseAction redundant! Come to think of it, I
suspect the remaining 25% can be farmed out into interceptors and that's the
whole lot.

The profile object / action interaction sounds interesting too. Can the
mechanism be mapped against tokens to identify the calling request in an app
allowing multiple windows?

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


Re: Struts 2.0 Application Lifecycle

Posted by Ted Husted <hu...@apache.org>.
On 11/5/06, Adam Hardy <ah...@cyberspaceroad.com> wrote:
> I hope you don't mind if I jump in on this thread, after reading the
> documentation refered to below.
>
> What is the S2 convention for loading up objects for use by the JSPs or other
> view logic?

It really isn't much different that Struts 1, except that the
ActionForm is combined with the Action, and all Actions are request
scope.

The simplest approach is to expose the object as a property on the
Action. The property can then fetch the object from the database or
session scope, as appropriate. If from a database, then the data
access logic might be encapsulated in a business facade, called by the
property. An application will often use a "support" object that
includes properties common to various Actions.


>
> Imagine a common-place user story where the user sees a list of items, and can
> choose one item, go to the 'edit item' page, submit changes, and be returned to
> the item list.
>
> On the edit submit, my action processes the edit and does a save, and does a
> Post-Redirect-Get back to the list.
>
> Where do I put the logic fetching the list again? Obviously I don't want it in
> the edit action. Do I put it in an action of its own, or do I put it in an
> interceptor or even a PreResultListener?

Oh, in the normal course, I don't think anything so exotic would be needed. :)

If we are fetching the list from a database, I'd put the actual logic
in a business facade. A good approach is to use Spring to instantiate
the business facade and then inject the business object into the
Action. Struts 2 can "autowire" Action properties from the Spring
configuration. If you give the Spring bean and the Action property the
same name and type, the framework will take care of the result.

* http://jroller.com/page/TedHusted?entry=struts_2_spring_love_fest

The list can be represented as a property on a base "support" Action
that other Action classes extend. All any Action needs to do is call
the property, and, behind the scenese, the property invokes the
business facade. The business facade itself can be autowired from
Spring, so the Action just needs to do is get the property name right!

If retrieving the list requires a key, a common approach is to create
a profile object that is stored in the session and can be retrieved as
a property on the base support Action.

-- HTH, Ted.
** http://husted.com/struts

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


Re: Struts 2.0 Application Lifecycle

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
I hope you don't mind if I jump in on this thread, after reading the 
documentation refered to below.

What is the S2 convention for loading up objects for use by the JSPs or other 
view logic?

Imagine a common-place user story where the user sees a list of items, and can 
choose one item, go to the 'edit item' page, submit changes, and be returned to 
the item list.

On the edit submit, my action processes the edit and does a save, and does a 
Post-Redirect-Get back to the list.

Where do I put the logic fetching the list again? Obviously I don't want it in 
the edit action. Do I put it in an action of its own, or do I put it in an 
interceptor or even a PreResultListener?

It seems that I can use a RedirectAction result type to do a Post-Redirect 
straight back to the name of the action I want without needing to quote its URL. 
That's the one I'm after, correct?


Adam



Wesslan on 05/11/06 06:19, wrote:
> A REALLY simple architecture overview picture:
> http://cwiki.apache.org/WW/home.html
> A more detailed architecture overview:
> http://cwiki.apache.org/WW/architecture.html
> 
> Hth,
> Peter
> 
> -----Original Message-----
> From: Mike Duffy [mailto:mduffy_lists@yahoo.com] 
> Sent: den 4 november 2006 18:04
> To: user@struts.apache.org
> Subject: Struts 2.0 Application Lifecycle
> 
> I've done a quick scan of the Struts 2.0 documentation.  I did not find a
> reference to the Struts 2.0 application life cycle.
> 
> Does anyone know of a reference that would be similar to the JSF article at
> the link below?
> 
> http://www-128.ibm.com/developerworks/java/library/j-jsf2/


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


RE: Struts 2.0 Application Lifecycle

Posted by Wesslan <fo...@wesslan.se>.
A REALLY simple architecture overview picture:
http://cwiki.apache.org/WW/home.html
A more detailed architecture overview:
http://cwiki.apache.org/WW/architecture.html

Hth,
Peter

-----Original Message-----
From: Mike Duffy [mailto:mduffy_lists@yahoo.com] 
Sent: den 4 november 2006 18:04
To: user@struts.apache.org
Subject: Struts 2.0 Application Lifecycle

I've done a quick scan of the Struts 2.0 documentation.  I did not find a
reference to the Struts 2.0 application life cycle.

Does anyone know of a reference that would be similar to the JSF article at
the link below?

http://www-128.ibm.com/developerworks/java/library/j-jsf2/

Thx.

Mike


 
____________________________________________________________________________
________
Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates
(http://voice.yahoo.com)


---------------------------------------------------------------------
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