⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib0100.html

📁 java外企软件工程师就业班 J2EE方向 《J2EE架构师手册》 电子书
💻 HTML
字号:
<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Chapter 15: Building the Presentation Layer</title>
<link rel="STYLESHEET" type="text/css" href="images/xpolecat.css">
<link rel="STYLESHEET" type="text/css" href="images/ie.content.css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/teamlib.gif" width="62" height="15" border="0" align="absmiddle"  alt="Team LiB"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href="LiB0099.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0101.html"><img src="images/next.gif" width="41" height="15" border="0" align="absmiddle" alt="Next Section"></a>
</div></td></tr></table>
<br>
<div class="chapter">
<a name="ch15"></a>
<h1 class="chapter-title"><span class="chapter-titlelabel">Chapter 15: </span>Building the Presentation Layer</h1><div class="section">
<h2 class="sect2-title">
<a name="480"></a>Overview</h2>
<a name="481"></a><a name="IDX-199"></a>
<p class="para">Objects in the presentation layer produce the pages or screens that users physically see and use. There are several aspects to the presentation side: static content, dynamic content, and navigation. For J2EE applications, HTML pages typically provide static content, and a combination of JSPs and servlets usually provide dynamic content. For applications that require special effects (e.g., mouse-overs), Javascript can be used in combination with either static or dynamically produced HTML. Users navigate pages using controls (e.g., push buttons) on the page. <a class="internaljump" href="#ch15fig01">Figure 15.1</a> depicts the role of the presentation layer.</p>
<div class="figure">
<a name="482"></a><a name="ch15fig01"></a><span class="figuremediaobject"><a href="images/fig216%5F01%5F0%2Ejpg" NAME="IMG_42" target="_parent"><img src="images/fig216_01.jpg" height="250" width="350" alt="Click To expand" border="0"></a></span>
<br style="line-height: 1">
<span class="figure-title"><span class="figure-titlelabel">Figure 15.1: </span>Using Presentation Objects Within a Layered Architecture</span>
</div>
<p class="para">Although it is technically possible to embed all presentation logic within JSPs, this type of architecture is difficult to maintain. A better method is to organize the presentation tier in a way that separates page display, user input validation, data processing, navigation, and security. This type of organization is often referred to as a model-view-controller (MVC) architecture. Although an MVC architecture results in more components to maintain, they are all relatively simple. For a more detailed discussion of the MVC pattern, see the Java Web site (<a target="_top" class="url" href="http://java.sun.com/blueprints/patterns/MVC.html">http://java.sun.com/blueprints/patterns/MVC.html</a>).</p>
<p class="para">The most common framework used to organize the presentation layer (and support an MVC architecture) is Struts, the open source package from <a name="483"></a><a name="IDX-200"></a>Apache introduced in <a href="LiB0030.html#129" target="_parent" class="chapterjump">chapter 5</a> and available from <a target="_top" class="url" href="http://jakarta.apache.org/struts/">http://jakarta.apache.org/struts/</a>. As with many other frameworks, some of Struts' features are commonly used and others are rarely used in practice. I'll concentrate on the package's most commonly used features here to give you a basic understanding of how to use it to implement the presentation layer. <a href="LiB0104.html#509" target="_parent" class="chapterjump">Spielman (2003)</a> is a good source for more in-depth information on Struts.</p>
<p class="para">Some developers use XSL transformations to produce dynamic content, but the technique is not a formal part of the J2EE specification and produces mixed success. Although you might consider this option if your data exists in XML format, formatting data with XML merely to run transformations on it to produce HTML usually results in high development and maintenance costs.</p>
<p class="para">Other types of presentation components are applets and Swing. These technologies are not J2EE specific and thus are out of the scope of this book. However, with a layered architecture, you certainly can deploy applets or Swing clients.</p>
<a name="484"></a><a name="IDX-201"></a>
<p class="last-para">In a layered architecture, the presentation layer is not self-contained. Presentation objects rely on client stubs and the value objects used with those stubs in the deployment layer for dynamic content. You can change aspects of any other layer without having to change the presentation layer. Likewise, you can make changes in presentation without affecting the other software layers.</p>
</div>
</div><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/teamlib.gif" width="62" height="15" border="0" align="absmiddle"  alt="Team LiB"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href="LiB0099.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0101.html"><img src="images/next.gif" width="41" height="15" border="0" align="absmiddle" alt="Next Section"></a>
</div></td></tr></table>
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -