Section 2.3. Exploring the Presentation Tier


2.3. Exploring the Presentation Tier

So, here we are at the presentation tier . The same principles of high cohesiveness and loose coupling are as applicable within this tier as they are across tiers. In the presentation tier, it is known as the Model / View / Controller (MVC) pattern.

  • The view is the actual screen. It is implemented using JSPs, CSS, and taglibs like the JSTL. It is concerned only about formatting the data in a pleasing way.

  • The model is the data. In a "View Cars" screen, the model is a Plain Old Java Object (POJO). In our case, it is a simple JavaBean named CarBean .

  • The controller mediates communication between the View and the Model. If a "viewCarList" request comes in, it retrieves the CarBeans from the persistence layer and hands them to the view. In a web application, the controller generally is a servlet.

Why Didn't You Use Framework X?

Perhaps the only thing more contentious among programmers than the argument over which text editor to use is which web framework to use. There are over 30 different Java-based web frameworks out there to choose from.

The dirty little secret of choosing a framework is that they are more similar than they are different. They all follow the same basic MVC pattern. So whether you choose to use Struts, JSF, Webwork, Tapestry, or any of the others, you are doing essentially the same thingusing a MVC framework.

While the frameworks all have similar philosophies, they differ in terms of implementation. Rather than choosing one and risk having you get lost in the details of the specific framework, we took the coward's way out and rolled our own MVC. We felt that this would allow us to clearly demonstrate how each J2EE technology interacts, and hopefully avoid the wrath of the jilted framework aficionado.

On most projects, we generally go with the framework the team has the most experience with, but you shouldn't feel obligated to choose any of them. We'll use a framework if the added functionality merits the additional overhead, but in the spirit of agile development we'll often use the "home grown" framework presented here for quick and dirty prototypes. By adhering to the basic principles of the MVC pattern, moving from our homegrown framework to a "real" one later in the development cycle is reasonably painless.




JBoss at Work. A Practical Guide
JBoss at Work: A Practical Guide
ISBN: 0596007345
EAN: 2147483647
Year: 2004
Pages: 197

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