At 6:40 AM -0700 7/29/05, Carl Smith wrote:
Struts privide strong C (of MVC) components, tyical of which are ActionServlet, Actions and RequestProcessors, but I am wondering which part is the M (of MVC).

Struts does not provide any part of the "M" (Model). I think this is what often leads new developers to put too much model-type code directly into Action classes.

The idea is that you somehow make your model available to Struts, most often through the Servlet Application Context, or perhaps through a JNDI service, and then actions look up your model classes and perform operations on them.

So, you can use Struts PlugIn class to trigger some initialization of the servlet context at startup time, although if you are using Servlet 2.3 or newer, there's not too much reason not to just use a ServletContextListener (unless you are using Struts "modules" feature and your initialization code needs to know which module it's part of.)

For the last 18 months or so, the Spring Framework has been my favorite tool for assembling model components and making them available in the application context. Spring includes quite a bit of direct support for Struts which makes this pretty easy to do.

Of course, Spring itself is also not the "M" in "MVC" -- we just use it to instantiate and initialize the service providers of our model layer.

Hope this helps.

Joe

--
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "Narrow minds are weapons made for mass destruction" -The Ex

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

Reply via email to