At 7:24 PM +0530 10/15/04, sachin wrote:
Thanks Joe

I have quit the idea of chaining actions.
It is true that Struts was never designed to for action forwarding.
My main concern was to have some common functionality independantly
which i can do better by creating own replica of Action , ActionForm and
ActionServlet etc . . and chaining can be avoided altogether ..

Note that where you might extend ActionServlet, you might also be able to use Struts PlugIns or J2EE ServletContextListeners to initialize supporting classes at application startup time instead. The reason to choose PlugIns is if you want your PlugIn to be aware of the Struts Module in which it was configured, or if you are still using Servlet 2.2, which didn't have ServletContextListener (or, if you're like me and you've been using PlugIns for a long time and are too lazy to switch.)


Typically, a PlugIn (or SCL) gets instantiated and triggered during the setup process of the ServletContext. The way I typically use it is to instantiate and configure some business expert class and put that class in the ServletContext under a well known key. Then, my Actions can reliably get that class out of the ServletContext and use it as a facade over business processes about which they shouldn't know any more than necessary. (I'll often have a base Action class which provides a typesafe "getXXXExpert" method which knows the ServletContext key and makes that all a little cleaner. More recently, we've inverted that model to make a base action which builds an ActionContext bean which encapsulates the request, response, form, and mapping, and which then has property accessors for these kinds of experts as well. It's a little more setup ahead of time, but I'm finding it a nice way to do things. On the dev list, we've talked a bit about making this something that is built in to Struts, but it hasn't gotten much past talk.

I suppose strictly speaking, this isn't all that different from your actions getting a custom subclass of ActionServlet and using it as the expert, but I'm more comfortable with a sharper separation of concerns.

Joe

--
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn back; I'll know I'm in the wrong place."
- Carlos Santana


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



Reply via email to