I am new to struts. Please clarify the struts framework from the MVC architecture point of view. Core application modules/Data Storage - Model Action classes/Event handlers -- Controller JSP forms/pages – View How about the XML description files?
The XML decriptor files are used by the controller so that it knows what it should do with each incoming request. The controller also uses the information providing in the action-mappings to determine what instance of the action class needs to be instantiated, what form is associated with the action (and instantiate that class if need be), as well as what to do in terms of forwarding. The action mappings define the wiring of your application because each ActionForward that is returned from an action, has to be defined in the struts-config.xml somewhere. Whether it is a global-forward of action specific forward. Check out chapters 2 & 6 for specifics on how to do various configuration tasks. HTH Sue
Those of you on the struts-users list can skip the following--Copy&Paste rules. 1) How about this one from my RL experience... I filled out a eBiz order form and mis-keyed my CC exp date. My transaction was rejected, and I was returned to the form... with nothing in it! I had to re-key everything. The Struts HTML tags take care of this problem for you, rather than having to trust that the browser will cache it or the user won't mind re-keying everything. HINT: If a user has to re-key something, they probably won't, resulting in lost business. 2) The key is that Struts helps you control the flow. You can skeleton out a whole app before it's even possible to write the business logic. I speak from experience here--I had a whole app laid out and assembled 6 months before the DBA's finished the schema for my data mart. I dropped in the logic, and voila, everything worked. Struts is *not* a business logic framework. It *is* a VC framework, waiting for your M. =) Trust me when I say once you learn it, it will save you time. 3) The key here is that Struts does everything for you that you'd have to write yourself. If you want to write it yourself, feel free. Meanwhile, I've got a set of wheels and I'm off building apps. =)
"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.
Hi there, Patterns, eh? Here is an interesting read... In pp. 577-578 of Manning's book on Struts, the author provides a list of well-known design patterns and states how they are implemented in Struts. The list is as follows: Pattern: Service to Worker Struts Component: ActionServlet, Action Pattern: Command, Controller, Front Controller, Singleton, Service Locator Struts Component: ActionServlet, Action Pattern: Dispatcher, Navigator Struts Component: ActionMapping, ActionServlet, Action, ActionForward Pattern: View Helper, Session Facade, Singleton Struts Component: Action Pattern: Value Object, Value Object Assembler Struts Component: ActionForm, ActionErrors, ActionMessages Pattern: View Helper Struts Component: ActionForm, ContextHelper, tag extensions Pattern: Composite View, Value Object Assembler Struts Component: Template taglib, Tiles taglib Pattern: Synchronizer Token Struts Component: Action Pattern: Decorator Struts Component: ActionMapping Very interesting! Darryl
What are the benifits of using Struts as MVC pattern when compared to JSP(V) - Servlet(C) - Java Class(M) concept.
Struts is a web application framework that encourages MVC application arcitecture. The framework is used to build web applications based on the MVC architurural pattern. It comes along with other useful things that would be nightmare for any developer (or team of developers) to implement and maintain like validation, request control, view layout. Struts include those extra stuff as part of its framework. Why re-invent the wheel again?
Darryl A. J. Staflund
Joined: Oct 06, 2002
Because framework manufacturing is a bit of a cottage industry :-) Darryl