Applying the Model-View-Controller Pattern


The Struts Model-View-Controller architecture will be a good fit for this application. Here's how it will work:

  • The Model component will be a Java bean that has basic set/get methods for reading and writing the name entered by the user . In this case, there also will be a method to save the data. In a more complex application, the Model may be a front for an EJB or Web service.

  • The View will be a single JSP file that presents information to the user. In addition, the View will also include a Struts form bean. A form bean is a regular Java bean with a couple of additional methods included to allow input resetting and validation.

  • The Controller component will be a Struts Action class. Action classes are the basic controller components in Struts. The Action class will coordinate the action in the application including making sure that the user doesn't try to say hello to the wrong people. The Action class also decides which View component to show the user.

In addition to the Model, View, and Controller components, the Struts configuration file ( struts-config.xml ) will be needed to determine how these components fit together.

The following basic ideas provide a quick view of the strengths of Struts:

  • The Struts framework enables you to break the application functions into components quickly and easily.

  • A configuration file ( struts-config.xml ) enables you to assemble the application from components. This simplifies the development process.

  • The framework provides a way to think about the application. That is, it provides a mental framework as well as a physical framework. Understanding the Struts Model-View-Controller framework will help you speed development because you'll be able to quickly break down complex applications into a series of simpler components.



Struts Kick Start
Struts Kick Start
ISBN: 0672324725
EAN: 2147483647
Year: 2002
Pages: 177

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net