husted      2004/03/07 12:22:52

  Modified:    web/example base.css index.jsp tour.html
               web/example/WEB-INF struts-config.xml
  Log:
  Update for index/welcome page.
  
  Revision  Changes    Path
  1.2       +9 -1      jakarta-struts/web/example/base.css
  
  Index: base.css
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/web/example/base.css,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- base.css  7 Mar 2004 02:20:37 -0000       1.1
  +++ base.css  7 Mar 2004 20:22:52 -0000       1.2
  @@ -19,3 +19,11 @@
   h4 { font-family: Arial,Helvetica,sans-serif; }
   h5 { font-family: Arial,Helvetica,sans-serif; }
   h6 { font-family: Arial,Helvetica,sans-serif; }
  +
  +font.hint {
  +  font-style:italic;
  +  font-size:80%;
  +  font-family:Arial,Helvetica,sans-serif;
  +  font-weight:bold;
  +  text-align:left;
  +}
  \ No newline at end of file
  
  
  
  1.19      +3 -3      jakarta-struts/web/example/index.jsp
  
  Index: index.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/web/example/index.jsp,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- index.jsp 21 Dec 2003 22:45:41 -0000      1.18
  +++ index.jsp 7 Mar 2004 20:22:52 -0000       1.19
  @@ -1,9 +1,9 @@
   <%@ taglib uri="WEB-INF/struts-logic.tld" prefix="logic" %>
  -<logic:redirect forward="welcome"/>
  +<logic:redirect action="welcome"/>
   
   <%--
   
  -Redirect default requests to Welcome global ActionForward.
  -By using a redirect, the user-agent will change address to match the path of our 
Welcome ActionForward. 
  +Redirect default requests to Welcome action.
  +By using a redirect, the user-agent will change address to match the path of our 
Welcome action.
   
   --%>
  
  
  
  1.4       +91 -72    jakarta-struts/web/example/tour.html
  
  Index: tour.html
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/web/example/tour.html,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- tour.html 7 Mar 2004 02:20:37 -0000       1.3
  +++ tour.html 7 Mar 2004 20:22:52 -0000       1.4
  @@ -14,11 +14,11 @@
     <blockquote>
       <h2>A Walking Tour of the Struts MailReader Demonstration Application</h2>
   
  -    <p><i>This article is meant to introduce a new user to Struts by "walking 
through" the example application. See the <a 
href="http://jakarta.apache.org/struts/";>Struts Users Guide and Strut's API</a> for 
more documentation.</i></p>
  +    <p><i>This article is meant to introduce a new user to Struts by "walking 
through" an application. See the <a href="http://jakarta.apache.org/struts/";>Struts 
Users Guide and Strut's API</a> for more documentation.</i></p>
   
  -    <p><i>This article is based on the working 1.0 builds of Struts. It is assumed 
that the reader has already installed a developer's copy of Struts and the example 
application (following the instructions in the Struts readme), and is ready to explore 
the example on their own development workstation (e.g. localhost).</i></p>
  +    <p><i>The MailReader application is based on the 1.2.0 build of Struts. To 
follow along, you should install the Mailreader application on your own development 
workstation (e.g. localhost).</i></p>
   
  -    <p><i>This article also assumes the reader has a basic understanding of the 
Java language, JavaBeans, Web applications and JavaServer Pages. For background on 
these topics, see the various Sun Javasoft product sites.</i></p>
  +    <p><i>The article assumes the reader has a basic understanding of the Java 
language, JavaBeans, web applications, and JavaServer Pages. For background on these 
technologies, see the <a 
href="http://jakarta.apache.org/struts/userGuide/preface.html";>Preface to the Struts 
User Guide</a>.</i></p>
       <hr />
   
       <ul>
  @@ -86,19 +86,42 @@
       </ul>
       <hr />
   
  -    <p>The standard Struts package comes with six applications: struts-test, 
struts-documentation, tiles-documentation, struts-validator, struts-upload, and 
struts-example. Regarding struts-example, the readme tells us that:</p>
  +    <p>The Struts distribution bundles four applications: struts-documentation, 
tiles-documentation, struts-example, and struts-examples. This document walks through 
the struts-example, also known as the "MailReader Demonstration Application".</p>
  +
  +    <p>The premise of the MailReader is that it is the first iteration of a portal 
application. This version allows users to register themselves and maintain a set of 
accounts with various mail servers. When completed, the application would let users 
read mail from their accounts.</p>
  +
  +    <h3><a name="index.jsp" id="index.jsp">index.jsp</a></h3>
  +
  +    <p>Struts allows developers to manage an application through "virtual pages" 
called <i>actions</i>. An accepted practice in Struts is to never link directly to 
server pages, but only to these actions. The actions are listed in a configuration 
file. By linking to actions, developers can "rewire" an application without editing 
the server pages.</p>
   
       <blockquote>
  -      <p>"This example is the beginnings of a portal application that would allow 
users to register themselves, and maintain a set of subscriptions they own to mail 
servers elsewhere on the Internet. When completed, this application will provide the 
ability to read mail from various mail servers, through the application."</p>
  +      <p><font class="hint">"Link actions not pages."</font></p>
       </blockquote>
   
  -    <p>The example is still incomplete, but still a very useful introduction to 
Struts. For more about installing Struts and the example application, see the Struts 
readme.</p>
  +    <p>A web application, like any other web site, can specify a list of welcome 
pages. Unfortunately, actions cannot be specified as a welcome page. Since there can 
be a list of pages, the web server looks for each page on the list before selecting 
one. Unfortunately, the web server doesn't see actions as pages and will never select 
one as a welcome page. So, how do we follow the Struts best practice of navigating 
through actions rather than pages?</p>
   
  -    <h3><a name="index.jsp" id="index.jsp">index.jsp</a></h3>
  +    <p>One solution is to use a server page to "bootstrap" a Struts action. A Java 
web application recognizes the idea of "forwarding" from one page to another page (or 
action). We can register the usual "index.jsp" as the welcome page and have it forward 
to a "welcome" action. Here's the MailReader's index.jsp:</p>
  +
  +     <blockquote>
  +      <p><code>&lt;%@ taglib uri="/tags/struts-logic" prefix="logic" %&gt;<br />
  +      &lt;logic:redirect forward="welcome"/&gt;</code></p>
  +    </blockquote>
   
  -    <p>Once installed, the example application is entered through a standard 
welcome page, index.jsp. This page offers two links, one to register with the 
application and one to login in (if you have already registered).</p>
  +    <p>At the top of the page, we import the "struts-logic" JSP tag library. 
(Again, see the <a 
href="http://jakarta.apache.org/struts/userGuide/preface.html";>Preface to the Struts 
User Guide</a> for more about the technologies underlying Struts.) The page itself 
consists of a single tag that redirects to the "welcome" action. The tag inserts the 
actual web address for the redirect when the page is rendered. But, where does the tag 
find the actual address to insert?</p>
   
  -    <p>Behind the scenes, index.jsp also checks for the existence of a database 
servlet and message resource. Both of these objects are referenced in the 
application's web.xml, and should be loaded before the index.jsp displays. If they are 
absent for any reason, index.jsp displays an error message.</p>
  +    <p>The list of actions, along with other Struts components, are registered 
through one or more Struts configuration files. The configuration files are written as 
XML documents and processed when the application starts. If we peek at the 
configuration file for the MailReader, we find a XML element for the "welcome" 
action.</p>
  +
  +     <blockquote>
  +      <p><code>&lt;!-- Display welcome page --&gt;<br />
  +      &lt;action path="/welcome"<br />
  +      forward="/welcome.jsp"/&gt;</code></p>
  +    </blockquote>
  +
  +    <h3>welcome.jsp</h3>
  +
  +    <p>The welcome page offers two links: one to register with the application and 
one to login in (if you have already registered).</p>
  +
  +    <p>Behind the scenes, welcome.jsp also checks for the existence of a database 
servlet and message resource. Both of these objects are referenced in the 
application's web.xml, and should be loaded before the welcome.jsp displays. If they 
are absent for any reason, welcome.jsp displays an error message.</p>
   
       <blockquote>
         <p><i>Note that the error messages are hardcoded into the welcome page; this 
way they can be displayed even if the message resource is missing. In other pages, a 
message resource is used to lookup and display messages, based on the user's 
locale.</i></p>
  @@ -108,10 +131,6 @@
   
       <p>If you check the application's web.xml, you will see how these objects are 
loaded. The message resource is loaded by the application parameter to the 
ActionServlet. When the ActionServlet initializes, it parses the 
ApplicationResources.properties in the package folder into the default message 
resource. If you change a message in the resource, and then reload the application, it 
will appear throughout the application.</p>
   
  -    <blockquote>
  -      <p><i>You can even reload the configuration and message resources without 
restarting the container. See the end of the web.xml file for details.</i></p>
  -    </blockquote>
  -
       <h4><a name="DatabaseServlet.java" 
id="DatabaseServlet.java">DatabaseServlet.java</a></h4>
   
       <p>The database object has it's own initialization block. The database servlet 
stores the database contents as a XML file, which is parsed by the Struts digester and 
loaded as a set of nested hashtables. The outer table is the list of user objects, 
each of which has its own inner hashtable of subscriptions. When you register, a user 
object is stored in this hashtable ... and when you login, the user object is stored 
within the session context.</p>
  @@ -203,12 +222,12 @@
       <blockquote>
         <p><code>&lt;!-- Process a user logon --&gt;<br />
         &lt;action<br />
  -      &nbsp;path="/logon"<br />
  -      &nbsp;type="org.apache.struts.webapp.example.LogonAction"<br />
  -      &nbsp;name="logonForm"<br />
  -      &nbsp;scope="request"<br />
  -      &nbsp;input="/logon.jsp"<br />
  -      &nbsp;&gt;&nbsp;<br />
  +      path="/logon"<br />
  +      type="org.apache.struts.webapp.example.LogonAction"<br />
  +      name="logonForm"<br />
  +      scope="request"<br />
  +      input="/logon.jsp"<br />
  +      &gt;<br />
         &lt;/action&gt;</code></p>
       </blockquote>
   
  @@ -217,9 +236,9 @@
       <blockquote>
         <p><code>&lt;!-- Logon form bean --&gt;<br />
         &lt;form-bean<br />
  -      &nbsp;name="logonForm"<br />
  -      &nbsp;type="org.apache.struts.webapp.example.LogonForm"&nbsp;<br />
  -      &nbsp;/&gt;</code></p>
  +      name="logonForm"<br />
  +      type="org.apache.struts.webapp.example.LogonForm"<br />
  +      /&gt;</code></p>
       </blockquote>
   
       <p>In the action mapping, the path property tells the ActionServlet to forward 
a request for logon.do to the LogonAction object. The input property tells the 
LogonAction object where it can pass control to get information from the user.</p>
  @@ -253,11 +272,11 @@
       <blockquote>
         <p><code>&lt;!-- Process a user logon --&gt;<br />
         &lt;action<br />
  -      &nbsp;path="/logon"<br />
  -      &nbsp;type="com.husted.struts.example2.LogonAction"<br />
  -      &nbsp;name="logonForm"<br />
  -      &nbsp;scope="request"<br />
  -      &nbsp;input="/logon.jsp"&gt;<br />
  +      path="/logon"<br />
  +      type="com.husted.struts.example2.LogonAction"<br />
  +      name="logonForm"<br />
  +      scope="request"<br />
  +      input="/logon.jsp"&gt;<br />
         &lt;/action&gt;</code></p>
       </blockquote>
   
  @@ -266,14 +285,14 @@
       <blockquote>
         <p><code>&lt;!-- Global Forward Definitions --&gt;<br />
         &lt;global-forwards&gt;<br />
  -      &nbsp;&lt;forward<br />
  -      &nbsp;&nbsp;name="logon"<br />
  -      &nbsp;&nbsp;path="/logon.jsp"<br />
  -      &nbsp;/&gt;<br />
  -      &nbsp;&lt;forward<br />
  -      &nbsp;&nbsp;name="success"<br />
  -      &nbsp;&nbsp;path="/mainMenu.jsp"<br />
  -      &nbsp;/&gt;<br />
  +      &lt;forward<br />
  +      name="logon"<br />
  +      path="/logon.jsp"<br />
  +      /&gt;<br />
  +      &lt;forward<br />
  +      name="success"<br />
  +      path="/mainMenu.jsp"<br />
  +      /&gt;<br />
         &lt;/global-forwards&gt;</code></p>
       </blockquote>
   
  @@ -357,12 +376,12 @@
   
       <blockquote>
         <p><code>&lt;logic:equal<br />
  -      &nbsp;name="registrationForm"<br />
  -      &nbsp;property="action"<br />
  -      &nbsp;scope="request"<br />
  -      &nbsp;value="Edit"<br />
  +      name="registrationForm"<br />
  +      property="action"<br />
  +      scope="request"<br />
  +      value="Edit"<br />
         &gt;<br />
  -      &nbsp; &lt;app:checkLogon/&gt;<br />
  +      &lt;app:checkLogon/&gt;<br />
         &lt;/logic:equal&gt;</code></p>
   
         <p><i>Note that the Struts html:form tag will refer to properties set by 
struts-config.xml and automatically create a registrationForm bean if one is not 
present. However, that does not happen until the form tag is processed within the 
page. Since this block appears before the html:form tag, a runtime error is exposed if 
you try to access registration.jsp directly (rather then going through the 
editRegistration.do action).</i></p>
  @@ -378,10 +397,10 @@
   
       <blockquote>
         <p><code>&lt;logic:equal<br />
  -      &nbsp;name="registrationForm"<br />
  -      &nbsp;property="action"<br />
  -      &nbsp;scope="request"<br />
  -      &nbsp;value="Edit"<br />
  +      name="registrationForm"<br />
  +      property="action"<br />
  +      scope="request"<br />
  +      value="Edit"<br />
         &gt;</code></p>
       </blockquote>
   
  @@ -413,11 +432,11 @@
   
       <blockquote>
         <p><code>&lt;ul&gt;<br />
  -      &nbsp; &lt;logic:iterate name="user" property="subscriptions" 
id="subscription"&gt;<br />
  -      &nbsp;&nbsp;&nbsp;&lt;li&gt;<br />
  -      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;bean:write name="subscription" 
property="host" filter="true" /&gt;<br />
  -      &nbsp;&nbsp;&nbsp;&lt;/li&gt;<br />
  -      &nbsp;&lt;/logic:iterate&gt;<br />
  +      &lt;logic:iterate name="user" property="subscriptions" 
id="subscription"&gt;<br />
  +      &lt;li&gt;<br />
  +      &lt;bean:write name="subscription" property="host" filter="true" /&gt;<br />
  +      &lt;/li&gt;<br />
  +      &lt;/logic:iterate&gt;<br />
         &lt;/ul&gt;</code></p>
   
         <p><i>This is another good example of how Struts works with the standard JSP 
tags, like bean. The filter option says to use convert HTML commands to their 
character entity. So a &lt; would be output in the HTML as &amp;lt;.</i></p>
  @@ -461,7 +480,7 @@
       <p>The Example application uses a subscription's host name (e.g. yahoo.com) as 
a primary key, which means you can only have one subscription for each host. It also 
means that to edit a subscription, all you need to know is the user and host. In fact, 
the editSubscription action is designed to create, edit, or delete a subscription if 
provided a user and host names in the request. The goal of LinkSubscriptionTag is then 
to output a block like:</p>
   
       <blockquote>
  -      
<p><code>&lt;A&nbsp;HREF=[path]editSubscription.do?action=[action]&amp;username=[user]&amp;host=[host]"&gt;[action]<br
 />
  +      <p><code>&lt;A 
HREF=[path]editSubscription.do?action=[action]&amp;username=[user]&amp;host=[host]"&gt;[action]<br
 />
         &lt;/A&gt;</code></p>
       </blockquote>
   
  @@ -469,7 +488,7 @@
   
       <blockquote>
         <p><code>&lt;app:linkSubscription<br />
  -      &nbsp; page="/editSubscription.do?action=Delete"&gt;Delete<br />
  +      page="/editSubscription.do?action=Delete"&gt;Delete<br />
         &lt;/app:linkSubscription&gt;</code></p>
       </blockquote>
   
  @@ -494,7 +513,7 @@
   
       <blockquote>
         <p><code>&lt;app:linkUser page="/editSubscription.do?action=Create"&gt;<br />
  -      &nbsp;&lt;bean:message key="registration.addSubscription"/&gt;<br />
  +      &lt;bean:message key="registration.addSubscription"/&gt;<br />
         &lt;/app:linkUser&gt;</code></p>
       </blockquote>
   
  @@ -506,7 +525,7 @@
   
       <blockquote>
         <p><code>&lt;app:linkUser page="/editSubscription.do?action=Create"&gt;<br />
  -      &nbsp;&lt;bean:message key="registration.addSubscription"/&gt;<br />
  +      &lt;bean:message key="registration.addSubscription"/&gt;<br />
         &lt;/app:linkUser&gt;</code></p>
       </blockquote>
   
  @@ -514,7 +533,7 @@
   
       <blockquote>
         <p><code>&lt;a 
href="/struts-example/editSubscription.do?action=Create&amp;amp;username=user"&gt;<br 
/>
  -      &nbsp;Add<br />
  +      Add<br />
         &lt;/a&gt;</code></p>
   
         <p><i>Note that anchor links with ampersands should use the character entity 
&amp;amp; as the LinkUserTag has done here (<a 
href="http://www.w3.org/TR/html401/appendix/notes.html#h-B.2.2";>http://www.w3.org/TR/html401/appendix/notes.html#h-B.2.2</a>).</i></p>
  @@ -529,19 +548,19 @@
       <blockquote>
         <p><code>&lt;!-- Subscription form bean --&gt;<br />
         &lt;form-bean<br />
  -      &nbsp;name="subscriptionForm"<br />
  -      &nbsp;type="org.apache.struts.webapp.example.SubscriptionForm"<br />
  +      name="subscriptionForm"<br />
  +      type="org.apache.struts.webapp.example.SubscriptionForm"<br />
         /&gt;</code></p>
   
         <p><code>&lt;!-- Edit mail subscription --&gt;<br />
         &lt;action path="/editSubscription"<br />
  -      &nbsp;type="org.apache.struts.webapp.example.EditSubscriptionAction"<br />
  -      &nbsp;name="subscriptionForm"<br />
  -      &nbsp;scope="request"<br />
  -      &nbsp;validate="false"<br />
  -      &nbsp;&gt;<br />
  -      &nbsp;&lt;forward name="failure" path="/mainMenu.jsp"/&gt;<br />
  -      &nbsp;&lt;forward name="success" path="/subscription.jsp"/&gt;<br />
  +      type="org.apache.struts.webapp.example.EditSubscriptionAction"<br />
  +      name="subscriptionForm"<br />
  +      scope="request"<br />
  +      validate="false"<br />
  +      &gt;<br />
  +      &lt;forward name="failure" path="/mainMenu.jsp"/&gt;<br />
  +      &lt;forward name="success" path="/subscription.jsp"/&gt;<br />
         &lt;/action&gt;</code></p>
   
         <p><i>When we've introduced these type of mappings before, and mentioned that 
the struts-config.xml was parsed when the ActionServlet was initialized. But we should 
make it clear that when the Struts digester parsed this file, it actually created 
standard Java objects, linked as properties to the controller. This means you don't 
have to edit Java source files just to add a bunch of "new" statements. (How cool is 
that?)</i></p>
  @@ -572,9 +591,9 @@
       <blockquote>
         <p><code>&lt;html:select property="type"&gt;<br />
         &lt;html:options<br />
  -      &nbsp;collection="serverTypes"<br />
  -      &nbsp;property="value"<br />
  -      &nbsp;labelProperty="label"<br />
  +      collection="serverTypes"<br />
  +      property="value"<br />
  +      labelProperty="label"<br />
         /&gt;<br />
         &lt;/html:select&gt;</code></p>
       </blockquote>
  @@ -612,12 +631,12 @@
   
       <blockquote>
         <p><code>&lt;logic:equal<br />
  -      &nbsp;name="subscriptionForm"<br />
  -      &nbsp;property="action"<br />
  -      &nbsp;scope="request"<br />
  -      &nbsp;value="Create"&gt;<br />
  -      &nbsp;&lt;html:submit&gt;<br />
  -      &nbsp;&nbsp;<b>&lt;bean:message key="button.save"/&gt;<br 
/></b>&nbsp;&lt;/html:submit&gt;<br />
  +      name="subscriptionForm"<br />
  +      property="action"<br />
  +      scope="request"<br />
  +      value="Create"&gt;<br />
  +      &lt;html:submit&gt;<br />
  +      <b>&lt;bean:message key="button.save"/&gt;<br /></b> &lt;/html:submit&gt;<br 
/>
         &lt;/logic:equal&gt;</code></p>
       </blockquote>
   
  
  
  
  1.38      +2 -4      jakarta-struts/web/example/WEB-INF/struts-config.xml
  
  Index: struts-config.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/web/example/WEB-INF/struts-config.xml,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- struts-config.xml 7 Mar 2004 01:07:11 -0000       1.37
  +++ struts-config.xml 7 Mar 2004 20:22:52 -0000       1.38
  @@ -7,7 +7,7 @@
   
   <struts-config>
     <display-name><![CDATA[
  -     account maintaince
  +     account maintenance
     ]]>
     </display-name>
       <description><![CDATA[
  @@ -37,7 +37,6 @@
       <forward   name="logoff"               path="/logoff.do"/>
       <forward   name="logon"                path="/logon.do"/>
       <forward   name="success"              path="/mainMenu.do"/>
  -    <forward   name="welcome"              path="/welcome.do"/>
     </global-forwards>
   
   
  @@ -46,8 +45,7 @@
   
         <!-- Display welcome page -->
         <action    path="/welcome"
  -                 type="org.apache.struts.actions.ForwardAction"
  -                 parameter="/welcome.jsp"/>
  +                 forward="/welcome.jsp"/>
   
         <!-- Display registration page -->
         <action    path="/registration"
  
  
  

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

Reply via email to