husted      01/01/21 20:44:08

  Modified:    src/doc/userGuide building_view.xml building_model.xml
                        building_controller.xml
  Log:
  Submitted by Ted Husted. Reformat example code in smaller font to enable printing 
(at least in Landscape mode).
  
  Revision  Changes    Path
  1.12      +24 -47    jakarta-struts/src/doc/userGuide/building_view.xml
  
  Index: building_view.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/doc/userGuide/building_view.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- building_view.xml 2001/01/21 12:57:51     1.11
  +++ building_view.xml 2001/01/22 04:44:07     1.12
  @@ -96,16 +96,12 @@
           <li><b>MyResources.properties</b> - Contains the messages in the default
               language for your server.  If your default language is English, you
               might have an entry like this:
  -            <pre>
  -          prompt.hello=Hello
  -            </pre></li>
  +            <code>prompt.hello=Hello</code></li>
           <li><b>MyResources_xx.properties</b> - Contains the same messages in the
               language whose ISO language code is "xx" (See the ResourceBundle
               Javadoc page for a link to the current list).  For a French version
               of the message shown above, you would have this entry:
  -            <pre>
  -          prompt.hello=Bonjour
  -            </pre>
  +            <code>prompt.hello=Bonjour</code>
               You can have resource bundle files for as many languages as you 
need.</li>
         </ul>
           
  @@ -133,25 +129,27 @@
         <p>
           Fulfilling this expectation is tedious and cumbersome when coding with
           standard HTML and JSP pages.  For example, an input element for a
  -        <code>username</code> field might look like this (in JSP)
  +        <code>username</code> field might look like this (in JSP):
  +       </p>
         
  -      
  -<pre>
  -  &lt;input type="text" name="username"
  -  value="&lt;%= loginBean.getUsername() %&gt;">
  -</pre>
  -      
  +      <p>
  +        <code>&lt;input type="text" name="username" 
  +        value="&lt;%= loginBean.getUsername() %&gt;"></code>
  +      </p>
         
  +      <p>
           which is difficult to type correctly, confuses HTML developers who are
           not knowledgeable about programming concepts, and can cause problems with
           HTML editors.  Instead, Struts provides a comprehensive facility for
           building forms, based on the Custom Tag Library facility of JSP 1.1.
           The case above would be rendered like this using Struts:
  -        
  -<pre>
  -  &lt;html:text property="username"/&gt;
  -</pre>
  +      </p>
  +      
  +      <p>        
  +        <code>&lt;html:text property="username"/&gt;</code>
  +      </p>
           
  +      <p> 
           with no need to explicitly refer to the JavaBean from which the initial
           value is retrieved.  That is handled automatically by the framework.
         </p>
  @@ -171,21 +169,15 @@
             makes dealing with forms much less painful than using straight HTML
             and standard JSP facilities.  Consider the following page (based on the
             example application included with Struts) named <code>logon.jsp</code>:
  -        </p>
  -        
  -<pre>
  -&lt;%@ page language="java" %&gt;
  +        </p>       
  +<pre><font size="-1">&lt;%@ page language="java" %&gt;
   &lt;%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %&gt;
   &lt;%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %&gt;
  -
  -
   &lt;html&gt;
   &lt;head&gt;
   &lt;title&gt;&lt;bean:message key="logon.title"/&gt;&lt;/title&gt;
   &lt;body bgcolor="white"&gt;
  -
   &lt;html:errors/&gt;
  -
   &lt;html:form name="logonForm" action="logon.do"&gt;
   &lt;table border="0" width="100%"&gt;
     &lt;tr&gt;
  @@ -218,11 +210,8 @@
     &lt;/tr&gt;
   &lt;/table&gt;
   &lt;/html:form&gt;
  -
   &lt;/body&gt;
  -&lt;/html&gt;
  -</pre>
  -          
  +&lt;/html&gt;</font></pre>         
           <p>
             The following items illustrate the key features of form handling in 
Struts,
             based on this example:
  @@ -291,52 +280,41 @@
           </p>
             
           <p>
  -<pre>
  -&lt;%@page language="java">
  -
  +<pre><font size="-1">&lt;%@page language="java">
   &lt;%@taglib uri="/WEB-INF/struts-html.tld" prefix="html">
  -
   &lt;html:form action="uploadAction.do">
     Please Input Text: &lt;html:text property="myText">&lt;br />
     Please Input The File You Wish to Upload:&lt;br />
     &lt;html:file property="myFile">&lt;br />
     &lt;html:submit />
   &lt;/html:form>
  -</pre>
  +</font></pre>
           </p>
           <p>
             The next step is to create your ActionForm bean:
           </p>
           <p>
  -<pre>
  -import javax.servlet.http.HttpServletRequest;
  +<pre><font size="-1">import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   import org.apache.struts.action.ActionForm;
   import org.apache.struts.action.ActionMapping;
   import org.apache.struts.upload.FormFile;
  -
   public class UploadForm extends ActionForm {
  -  
     protected String myText;
     protected FormFile myFile;
  -  
     public void setMyText(String text) {
       myText = text;
     }
  -  
     public String getMyText() {
       return myText;
     }
  -  
     public void setMyFile(FormFile file) {
       myFile = file;
     }
  -  
     public FormFile getMyFile() {
       return myFile;
     }
  -}
  -</pre>
  +}</font></pre>
           </p>
           
           <p>
  @@ -419,10 +397,9 @@
             offers an additional facility to validate the input fields it has 
received.
             To utilize this feature, override the following method in your ActionForm 

             class:
  -  <pre>
  -          public ActionErrors validate(ActionMapping mapping,
  +  <pre><font size="-1">public ActionErrors validate(ActionMapping mapping,
                                 HttpServletRequest request)
  -  </pre>
  +  </font></pre>
           </p>
           
           <p>
  
  
  
  1.9       +8 -13     jakarta-struts/src/doc/userGuide/building_model.xml
  
  Index: building_model.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/doc/userGuide/building_model.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- building_model.xml        2001/01/21 12:57:51     1.8
  +++ building_model.xml        2001/01/22 04:44:07     1.9
  @@ -59,20 +59,18 @@
           a bean stored as a request attribute in a servlet like this:
         </p>
           
  -<pre>
  -   MyCart mycart = new MyCart(...);
  -   request.setAttribute("cart", mycart);
  -</pre>
  +      <p><code>MyCart mycart = new MyCart(...);<br />
  +        request.setAttribute("cart", mycart);
  +      </code></p>
         
         <p>
           is immediately visible to a JSP page which this servlet forwards to,
           using a standard action tag like this:
         </p>
           
  -      <pre>
  -        &lt;jsp:useBean id="cart" scope="request"
  +      <p><code>&lt;jsp:useBean id="cart" scope="request"<br />
           class="com.mycompany.MyApp.MyCart"/&gt;
  -      </pre>
  +      </code></p>
       </section>
       
       <section name="2.3 ActionForm Beans" href="actionform">
  @@ -232,14 +230,12 @@
           from within a Action perform method. 
         </p>
         <p>
  -<pre>
  -  public ActionForward perform(ActionMapping mapping,
  +<pre><font size="-1">public ActionForward perform(ActionMapping mapping,
                         ActionForm form,
                         HttpServletRequest request,
                         HttpServletResponse response) {
       try {
  -      DataSource dataSource = servlet.findDataSource(null);
  -      
  +      DataSource dataSource = servlet.findDataSource(null);      
         Connection myConnection = dataSource.getConnection();
         //do what you wish with myConnection
       }
  @@ -251,8 +247,7 @@
         //sure the connection is closed
         myConnection.close();
       }
  -  }
  -</pre>
  +  }</font></pre>
         </p>
         
         <p align="center">
  
  
  
  1.8       +25 -42    jakarta-struts/src/doc/userGuide/building_controller.xml
  
  Index: building_controller.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/doc/userGuide/building_controller.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- building_controller.xml   2001/01/21 12:57:51     1.7
  +++ building_controller.xml   2001/01/22 04:44:07     1.8
  @@ -39,8 +39,7 @@
         
         <p>The <code>Action</code> class defines two methods that could be
           executed depending on your servlet environment:
  -<pre>
  -   public ActionForward perform(ActionMapping mapping,
  +<pre><font size="-1">public ActionForward perform(ActionMapping mapping,
                         ActionForm form,
                         ServletRequest request,
                       ServletResponse response)
  @@ -51,7 +50,7 @@
                         HttpServletRequest request,
                       HttpServletResponse response)
     throws IOException, ServletException   
  -</pre>
  +</font></pre>
         </p>
         
         <p>
  @@ -115,10 +114,8 @@
               You should trap all such exceptions
               in the logic of your <code>perform()</code> method, and log them to the
               application logfile (along with the corresponding stack trace) by
  -            calling:
  -            <pre>
  -          servlet.log("Error message text", exception);
  -            </pre></li>
  +            calling:<br />
  +            <code>servlet.log("Error message text", exception);</code></li>
           <li>As a general rule, allocating scarce resources and keeping them across
               requests from the same user (in the user's session) can cause
               scalability problems.  You should strive to release such resources
  @@ -268,19 +265,15 @@
           to illustrate the requirements.  Note that the entries for all the other 
actions
           are left out:
         </p>
  -<pre>
  -  &lt;struts-config>
  +<pre><font size="-1">&lt;struts-config>
         &lt;form-beans>
           &lt;form-bean name="logonForm"
                   type="org.apache.struts.example.LogonForm">
  -      &lt;/form-beans>
  -      
  +      &lt;/form-beans>      
         &lt;global-forwards type="org.apache.struts.action.ActionForward">
         &lt;forward name="logon" path="/logon.jsp" redirect="false" /> 
  -    &lt;/global-forwards>
  -      
  -    &lt;action-mappings&gt;
  -     
  +    &lt;/global-forwards>      
  +    &lt;action-mappings&gt;     
         &lt;action path="/logon" 
                 type="org.apache.struts.example.LogonAction"
                 name="logonForm"
  @@ -290,8 +283,7 @@
                 validate="true" />          
       &lt;/action-mappings&gt;
    &lt;/struts-config>
  -</pre>
  -      
  +</font></pre>      
         <p>
           First the form bean is defined.  A basic bean of class 
"org.apache.struts.example.LogonForm"
           is mapped to the logical name "logonForm".  This name is used as a session 
or request attribute
  @@ -318,8 +310,7 @@
           of struts-config.xml:
         </p>
         <p>
  -<pre>
  -  &lt;struts-config>
  +<pre><font size="-1">&lt;struts-config>
       &lt;data-sources>
         &lt;data-source autoCommit="false"
                    description="Example Data Source Description"
  @@ -331,7 +322,7 @@
                      user="myusername"/>
       &lt;/data-sources>
     &lt;/struts-config>
  -</pre>
  +</font></pre>
         </p>  
         <p>
           For information on how to retrieve the data source, see the 
  @@ -354,8 +345,7 @@
           <p>
             Add an entry defining the action servlet itself, along with the 
appropriate
             initialization parameters.  Such an entry might look like this:
  -<pre>
  -   &lt;servlet&gt;
  +<pre><font size="-1">&lt;servlet&gt;
        &lt;servlet-name&gt;action&lt;/servlet-name&gt;
        
&lt;servlet-class&gt;org.apache.struts.action.ActionServlet&lt;/servlet-class&gt;
        &lt;init-param&gt;
  @@ -376,7 +366,7 @@
        &lt;/init-param&gt;
        &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  -</pre>
  +</font></pre>
           </p>
           
           <p>
  @@ -475,19 +465,17 @@
             path part) with a particular value to be passed to this servlet.  Such an
             entry might look like this:
           </p>
  -<pre>
  -   &lt;servlet-mapping&gt;
  +<pre><font size="-1">&lt;servlet-mapping&gt;
        &lt;servlet-name&gt;action&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/execute/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  -</pre>
  +</font></pre>
           
           <p>
             which means that a request URI to match the <code>/logon</code> path
  -          described earlier might look like this:
  -          <pre>
  -              http://www.mycompany.com/myapplication/execute/logon
  -          </pre>
  +          described earlier might look like this:</p>
  +        <p>
  +          <code> http://www.mycompany.com/myapplication/execute/logon</code>
           </p>
           
           <p>
  @@ -502,20 +490,17 @@
             to the <code>*.jsp</code> pattern so that it is called to process every
             JSP page that is requested.  To use the <code>*.do</code> extension (which
             implies "do something"), the mapping entry would look like this:
  -<pre>
  -   &lt;servlet-mapping&gt;
  +<pre><font size="-1">&lt;servlet-mapping&gt;
        &lt;servlet-name&gt;action&lt;/servlet-name&gt;
        &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  -</pre>
  +</font></pre>
           </p>
           
           <p>
             and a request URI to match the <code>/logon</code> path described
  -          earlier might look like this:
  -          <pre>
  -              http://www.mycompany.com/myapplication/logon.do
  -          </pre>
  +          earlier might look like this:<br />
  +          <code> http://www.mycompany.com/myapplication/logon.do</code>
           </p>
         </section>
         
  @@ -547,10 +532,8 @@
           
           <p>
             Below is how you would define all taglibs for use within your application,
  -          in reality you would only specify the taglib's that your application will 
use:
  -          
  -<pre>
  - &lt;taglib&gt;
  +          in reality you would only specify the taglib's that your application will 
use:          
  +<pre><font size="-1">&lt;taglib&gt;
      &lt;taglib-uri&gt;/WEB-INF/struts-bean.tld&lt;/taglib-uri&gt;
      &lt;taglib-location&gt;/WEB-INF/struts-bean.tld&lt;/taglib-location&gt;
    &lt;/taglib&gt;
  @@ -566,7 +549,7 @@
      &lt;taglib-uri&gt;/WEB-INF/struts-template.tld&lt;/taglib-uri&gt;
      &lt;taglib-location&gt;/WEB-INF/struts-template.tld&lt;/taglib-location&gt;
    &lt;/taglib&gt;
  -</pre>
  +</font></pre>
           </p>
             
           <p>
  
  
  

Reply via email to