Author: husted
Date: Thu Nov  3 19:01:48 2005
New Revision: 330693

URL: http://svn.apache.org/viewcvs?rev=330693&view=rev
Log:
Update "Accessing a Database" for 1.3.0.

Modified:
    struts/core/trunk/xdocs/faqs/actionForm.xml
    struts/core/trunk/xdocs/faqs/db-howto.xml
    struts/core/trunk/xdocs/faqs/index.xml

Modified: struts/core/trunk/xdocs/faqs/actionForm.xml
URL: 
http://svn.apache.org/viewcvs/struts/core/trunk/xdocs/faqs/actionForm.xml?rev=330693&r1=330692&r2=330693&view=diff
==============================================================================
--- struts/core/trunk/xdocs/faqs/actionForm.xml (original)
+++ struts/core/trunk/xdocs/faqs/actionForm.xml Thu Nov  3 19:01:48 2005
@@ -3,7 +3,7 @@
 <document url="./actionForm.xml">
 
  <properties>
-  <title>Building an ActionForm</title>
+  <title>Building an ActionForm - Apache Struts</title>
  </properties>
 
 <body>
@@ -13,10 +13,10 @@
 
     <p>
     This is a simple example of a login form to illustrate how Struts
-    makes dealing with forms much less painful than using straight HTML
+    Core makes dealing with forms much less painful than using straight HTML
     and standard JSP facilities.  
-    Consider the following page (based on the example MailReader application 
-    included  with Struts) named <code>logon.jsp</code>:
+    Consider the following page (based on the Struts MailReader, found in 
+    the Application subproject) named <code>logon.jsp</code>:
     </p>
 
 <hr/>
@@ -77,7 +77,7 @@
 <hr/>
 
     <p>
-    The following items illustrate the key features of form handling in Struts,
+    The following items illustrate the key features of form handling in Struts 
Core,
     based on this example:
     </p>
 
@@ -85,7 +85,7 @@
 
         <li>
         The <code>taglib</code> directive tells the JSP page compiler where to
-        find the <em>tag library descriptor</em> for the Struts tag library.  
+        find the <em>tag library descriptor</em> for the Struts JSP tags.  
         In this case, we are using <code>bean</code> as the prefix that 
         identifies tags from the struts-bean library, and "html" as the prefix 
 
         that identifies tags from the struts-html library.  
@@ -150,7 +150,7 @@
         configuration.
         The <code>logon</code> mapping tells the tag that the form bean is
         stored in the session context under the key <code>logonForm</code>.
-        The Struts developer provides the Java implementation of the 
+        The Struts Core developer provides the Java implementation of the 
         ActionForm bean, subclassing the Struts class <code>ActionForm</code>
         (see <a 
href="../userGuide/building_controller.html#4_3_ActionForm_Classes">Building
         Controller</a> components).
@@ -264,13 +264,13 @@
 
     <p>
     Look at the Javadocs for 
-    <code><a 
href="../struts-core/apidocs/org/apache/struts/upload/FormFile.html">
+    <code><a href="../apidocs/org/apache/struts/upload/FormFile.html">
     FormFile</a></code> to see the methods it exposes to manipulate files in 
     file uploading.
     Also look at the Javadocs for
-    <a 
href="../struts-core/apidocs/org/apache/struts/action/ActionServlet.html">
+    <a href="../apidocs/org/apache/struts/action/ActionServlet.html">
     ActionServlet</a> and
-    <a 
href="../struts-core/apidocs/org/apache/struts/action/ActionMapping.html">
+    <a href="../apidocs/org/apache/struts/action/ActionMapping.html">
     ActionMapping</a> for the various parameters you can specify to change 
     how files are uploaded.  
     Basically in your <code>execute</code> method in your action class you 

Modified: struts/core/trunk/xdocs/faqs/db-howto.xml
URL: 
http://svn.apache.org/viewcvs/struts/core/trunk/xdocs/faqs/db-howto.xml?rev=330693&r1=330692&r2=330693&view=diff
==============================================================================
--- struts/core/trunk/xdocs/faqs/db-howto.xml (original)
+++ struts/core/trunk/xdocs/faqs/db-howto.xml Thu Nov  3 19:01:48 2005
@@ -1,13 +1,12 @@
 <?xml version="1.0"?>
 
-<document url="./database.xml">
+<document url="./db-howto.xml">
 
  <properties>
-  <title>Accessing a Database</title>
+  <title>Accessing a Database - Apache Struts</title>
  </properties>
 
 <body>
-<chapter href="actionForm" name="How to Access a Database">
 
 <section name="Accessing a Database" href="database">
 
@@ -52,8 +51,8 @@
     </p>
 
     <p>
-    The MailReader example application bundled with Struts demonstrates
-    how this is usually done. The MailReader uses the DAO (Data Access Object)
+    The Struts MailReader (see the Struts Applications subproject) shows 
+    how this is usually done. MailReader uses the DAO (Data Access Object)
     pattern to separate the persistence layer from the (Struts) control layer.
     MailReader defines a DAO interface that the Actions can call, it then
     defines a implementation that uses a database stored in main memory.
@@ -72,15 +71,15 @@
     As you gain experience, you will find ways to combine your Action classes,
     say by using the DispatchAction.
     It's even possible to use a single "framework" Action to call all of your
-    business classes, as is done with Scaffold ProcessAction in the contrib
-    folder.
+    business classes, as is done with Scaffold ProcessAction in the Sandbox
+    subproject.
     </p>
 
     <p>
-    Using fewer Actions does require a deeper understanding of how Struts and
-    MVC frameworks operate.
+    Using fewer Actions does require a deeper understanding of how Struts Core 
+    and MVC frameworks operate.
     Don't hesitate to err on the side of creating more Action classes at first.
-    The Struts configuration makes it easy to refactor your Actions later,
+    The Struts Core configuration makes it easy to refactor your Actions later,
     since you can change the Action type without changing anything else in the
     application.
     </p>
@@ -132,187 +131,6 @@
 
     </section>
 
-    <section name="The Struts DataSource Manager" href="manager">
-
-    <p>
-    Ideally, the business logic layer should encapsulate the data access
-    details, including acquiring a database connection.
-    However, some older application designs expect that the caller be able to
-    provide a database connection or DataSource instance.
-    When you need to access a legacy design, the Struts DataSource manager can
-    make it easy for your Action class to produce these resources on demand.
-    </p>
-
-    <p>
-    <strong>NOTE:</strong> It is preferred that data connectivity be handled
-    directly by the business classes, usually via JNDI. The Struts DataSource
-    manager should only be used with legacy business classes that don't provide
-    their own  connectivity. When possible, we <b>strongly</b> recommend use of
-    the standard DAO pattern, so that the Action classes do not need to know
-    anything about the persitence mechanism. <strong>The DataSource manager is 
being
-    retained in Struts 1.x for backward compatibility but may not be retained
-    in Struts 2.x or later.</strong>
-    </p>
-
-    <p>
-    The Struts DataSource manager is configured as an element in the
-    <a href="../userGuide/configuration.html#data-source_config">
-    Struts configuration file</a> (struts-config.xml).
-    The manager can be used to deploy any connection pool that implements the
-    <code>javax.sql.DataSource</code> interface and is configurable totally
-    from JavaBean properties.
-    If your DBMS or container provides a connection pool that meets these
-    requirements, then that component might be your first choice.
-    </p>
-
-    <p>
-    The Jakarta Commons dbcp's BasicDataSource
-    [<code>org.apache.commons.dbcp.BasicDataSource</code>] also works well
-    with the DataSource manager, if a native component is not available.
-    DBCP is not supplied as part of the Struts distribution. You can obtain 
-    it from <a href="http://jakarta.apache.org/commons/dbcp/downloads.html";>
-    Commons DBCP</a>.
-    </p>
-    
-    <p>
-    <strong>Note:</strong> The Generic DataSource which was included with 
previous 
-    versions of Struts has been removed as of release 1.2.0 in favor of 
-    plugging in the BasicDataSource, or another DataSource implementation.
-    </p>
-
-    <p>
-    This is how you would specify a DBCP BasicDataSource for your application:
-    </p>
-
-<pre><code><![CDATA[
-<data-sources>
-<!-- configuration for commons BasicDataSource -->
-<data-source type="org.apache.commons.dbcp.BasicDataSource">
-    <set-property
-      property="driverClassName"
-      value="org.postgresql.Driver" />
-    <set-property
-      property="url"
-      value="jdbc:postgresql://localhost/mydatabase" />
-    <set-property
-      property="username"
-      value="me" />
-    <set-property
-      property="password"
-      value="test" />
-    <set-property
-      property="maxActive"
-      value="10" />
-    <set-property
-      property="maxWait"
-      value="5000" />
-    <set-property
-      property="defaultAutoCommit"
-      value="false" />
-    <set-property
-      property="defaultReadOnly"
-      value="false" />
-    <set-property
-      property="validationQuery"
-      value="SELECT COUNT(*) FROM market" />
-</data-source>
-</data-sources>
-]]></code></pre>
-
-    <p>
-    Note that you can define as many datasource objects as your application
-    requires and refer to each using a logical name.
-    This can be useful in providing better security or scalability, or even
-    to test datasource implementations against each other.
-    </p>
-
-    <p>
-    After a DataSource is defined, here is an example of using the
-    manager to establish a connection from within an Action's
-    <code>execute</code> method.
-    </p>
-
-<pre><code>
-public ActionForward
-       execute(ActionMapping mapping,
-               ActionForm form,
-               HttpServletRequest request,
-               HttpServletResponse response) throws Exception
-{
- javax.sql.DataSource dataSource;
- java.sql.Connection myConnection;
- try {
-  dataSource = getDataSource(request);
-  myConnection = dataSource.getConnection();
-  // do what you wish with myConnection
- } catch (SQLException sqle) {
-    getServlet().log("Connection.process", sqle);
- } finally {
-    //enclose this in a finally block to make
-    //sure the connection is closed
-    try {
-       myConnection.close();
-    } catch (SQLException e) {
-       getServlet().log("Connection.close", e);
-    }
-   }
-}
-</code></pre>
-
-    <p>
-    <em>Note: If you use the Commons BasicDataSource with Struts,
-    the query you provide for the pingQuery attribute (if you choose to
-    include it) must return at least one row.</em>
-    </p>
-
-    <p>
-    <strong>Example:</strong> <code>SELECT COUNT(*) FROM VALIDTABLE</code>
-    </p>
-
-    <p>
-    Just be sure you to replace "VALIDTABLE" with the name of a valid table
-    in your database.
-    </p>
-
-</section>
-
-<section name="Using Multiple Datasources" href="multi_dsrc">
-    <p>
-    If you need more than one data source in a module, you can include a key
-    attribute in the data-source element:
-    </p>
-<pre><code><![CDATA[
-<data-sources>
-   <data-source key="A" type="org.apache.commons.dbcp.BasicDataSource">
-      ... properties as before ...
-   </data-source>
-   <data-source key="B" type="org.apache.commons.dbcp.BasicDataSource">
-      ... properties as before ...
-   </data-source>
-   ...
-</data-sources>
-]]></code></pre>
-
-    <p>
-    Which can then be accessed by including the key ("A" in this case) as an
-    additional parameter to the Action.getDataSource() method.
-    </p>
-
-<pre><code>
-   ...
-   try {
-      dataSourceA = getDataSource(request, "A");
-      dataSourceB = getDataSource(request, "B");
-   ...
-</code></pre>
-
-    <p>
-    Each module can have as many data sources as it needs. The keys only
-    need to be unique within a module since the struts module system maintains
-    a name space for the items in each module to protect you from name
-    clashes.
-    </p>
- </section>
 
 <section href="more" name="See Also">
 
@@ -359,7 +177,7 @@
     </p>
 
     <p>
-        Happily, the Struts tags don't care what type of bean you use with 
them.
+        Happily, the Struts JSP tags don't care what type of bean you use with 
them.
         You could even output a ResultSet directly.
         But a ResultSet retains a connection to the database, and passing "all 
that" directly to a JSP gets messy.
         So what's a developer to do?
@@ -380,7 +198,6 @@
 
 </section>
 
-</chapter>
 </body>
 </document>
 

Modified: struts/core/trunk/xdocs/faqs/index.xml
URL: 
http://svn.apache.org/viewcvs/struts/core/trunk/xdocs/faqs/index.xml?rev=330693&r1=330692&r2=330693&view=diff
==============================================================================
--- struts/core/trunk/xdocs/faqs/index.xml (original)
+++ struts/core/trunk/xdocs/faqs/index.xml Thu Nov  3 19:01:48 2005
@@ -37,6 +37,10 @@
  <ul>
 
     <li>
+    <a href="db-howto.html">Accessing a Database</a>
+    </li>
+
+    <li>
     <a href="actionForm.html">Building an Action Form</a>
     </li>
     
@@ -55,6 +59,7 @@
     <li>
     <a href="struts-el.html">Struts EL Extension</a>
     </li>
+
 
  </ul>
 



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

Reply via email to