geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jb...@apache.org
Subject svn commit: r667090 - in /geronimo/samples/branches/2.1/samples/inventory: inventory-jetty/src/main/plan/ inventory-tomcat/ inventory-tomcat/src/main/plan/ inventory-war/src/main/java/org/apache/geronimo/samples/inventory/dao/ inventory-war/src/main/ja...
Date Thu, 12 Jun 2008 13:46:09 GMT
Author: jbohn
Date: Thu Jun 12 06:46:09 2008
New Revision: 667090

URL: http://svn.apache.org/viewvc?rev=667090&view=rev
Log:
merge 666872 from samples/trunk - general code cleanup, add back db script

Added:
    geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/exception/ItemException.java
      - copied unchanged from r666872, geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/exception/ItemException.java
    geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/resources/
      - copied from r666872, geronimo/samples/trunk/samples/inventory/inventory-war/src/main/resources/
    geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/resources/InventoryDB.sql
      - copied unchanged from r666872, geronimo/samples/trunk/samples/inventory/inventory-war/src/main/resources/InventoryDB.sql
Removed:
    geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/util/
    geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/WEB-INF/geronimo-web.xml
Modified:
    geronimo/samples/branches/2.1/samples/inventory/inventory-jetty/src/main/plan/plan.xml
    geronimo/samples/branches/2.1/samples/inventory/inventory-tomcat/pom.xml
    geronimo/samples/branches/2.1/samples/inventory/inventory-tomcat/src/main/plan/plan.xml
    geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/dao/ItemDAO.java
    geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/services/InventoryManager.java
    geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/AddItemServlet.java
    geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/IssueingServlet.java
    geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/jsp/issue.jsp
    geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/jsp/recv.jsp
    geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/welcome.jsp

Modified: geronimo/samples/branches/2.1/samples/inventory/inventory-jetty/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/2.1/samples/inventory/inventory-jetty/src/main/plan/plan.xml?rev=667090&r1=667089&r2=667090&view=diff
==============================================================================
--- geronimo/samples/branches/2.1/samples/inventory/inventory-jetty/src/main/plan/plan.xml
(original)
+++ geronimo/samples/branches/2.1/samples/inventory/inventory-jetty/src/main/plan/plan.xml
Thu Jun 12 06:46:09 2008
@@ -28,4 +28,11 @@
         <ref-name>jdbc/InventoryDS</ref-name>
         <resource-link>SampleTxDatasource</resource-link>
     </resource-ref>
+    <gbean name="DBInitialization" class="org.apache.geronimo.connector.DatabaseInitializationGBean">
+        <attribute name="testSQL">select * from item</attribute>
+        <attribute name="path">InventoryDB.sql</attribute>
+        <reference name="DataSource">
+            <name>SampleTxDatasource</name>
+        </reference>
+    </gbean>
 </web-app>
\ No newline at end of file

Modified: geronimo/samples/branches/2.1/samples/inventory/inventory-tomcat/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/2.1/samples/inventory/inventory-tomcat/pom.xml?rev=667090&r1=667089&r2=667090&view=diff
==============================================================================
--- geronimo/samples/branches/2.1/samples/inventory/inventory-tomcat/pom.xml (original)
+++ geronimo/samples/branches/2.1/samples/inventory/inventory-tomcat/pom.xml Thu Jun 12 06:46:09
2008
@@ -113,23 +113,23 @@
                         <includeVersion>true</includeVersion>
                     </useMavenDependencies>
                     <category>Sample</category>
-                    <instance>
-                        <plugin-artifact>
-                            <prerequisite>
-                                <id>
-                                    <groupId>org.apache.geronimo.configs</groupId>
-                                    <artifactId>tomcat6</artifactId>
-                                </id>
-                                <resource-type>Web Container</resource-type>
-                                <description>
-                                    This version of the application works with the Geronimo/Tomcat
distribution.
-                                    It is not intended to run in the Geronimo/Jetty distribution.
-                                    There is a separate version of the application that works
with Jetty.
-                                    Please install the version appropriate to your Geronimo
distribution.
-                                </description>
-                            </prerequisite>
-                        </plugin-artifact>
-                    </instance>
+                    <!--<instance>-->
+                        <!--<plugin-artifact>-->
+                            <!--<prerequisite>-->
+                                <!--<id>-->
+                                    <!--<groupId>org.apache.geronimo.configs</groupId>-->
+                                    <!--<artifactId>tomcat6</artifactId>-->
+                                <!--</id>-->
+                                <!--<resource-type>Web Container</resource-type>-->
+                                <!--<description>-->
+                                    <!--This version of the application works with the
Geronimo/Tomcat distribution.-->
+                                    <!--It is not intended to run in the Geronimo/Jetty
distribution.-->
+                                    <!--There is a separate version of the application
that works with Jetty.-->
+                                    <!--Please install the version appropriate to your
Geronimo distribution.-->
+                                <!--</description>-->
+                            <!--</prerequisite>-->
+                        <!--</plugin-artifact>-->
+                    <!--</instance>-->
                 </configuration>
             </plugin>
         </plugins>

Modified: geronimo/samples/branches/2.1/samples/inventory/inventory-tomcat/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/2.1/samples/inventory/inventory-tomcat/src/main/plan/plan.xml?rev=667090&r1=667089&r2=667090&view=diff
==============================================================================
--- geronimo/samples/branches/2.1/samples/inventory/inventory-tomcat/src/main/plan/plan.xml
(original)
+++ geronimo/samples/branches/2.1/samples/inventory/inventory-tomcat/src/main/plan/plan.xml
Thu Jun 12 06:46:09 2008
@@ -28,4 +28,11 @@
         <ref-name>jdbc/InventoryDS</ref-name>
         <resource-link>SampleTxDatasource</resource-link>
     </resource-ref>
+    <gbean name="DBInitialization" class="org.apache.geronimo.connector.DatabaseInitializationGBean">
+        <attribute name="testSQL">select * from item</attribute>
+        <attribute name="path">InventoryDB.sql</attribute>
+        <reference name="DataSource">
+            <name>SampleTxDatasource</name>
+        </reference>
+    </gbean>
 </web-app>
\ No newline at end of file

Modified: geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/dao/ItemDAO.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/dao/ItemDAO.java?rev=667090&r1=667089&r2=667090&view=diff
==============================================================================
--- geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/dao/ItemDAO.java
(original)
+++ geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/dao/ItemDAO.java
Thu Jun 12 06:46:09 2008
@@ -24,156 +24,176 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+
 import org.apache.geronimo.samples.inventory.Item;
-import org.apache.geronimo.samples.inventory.util.DBManager;
+import org.apache.geronimo.samples.inventory.exception.ItemException;
 
 
 public class ItemDAO {
 
-    public List getItems() {
-        ArrayList items = new ArrayList();
+    private final DataSource ds;
 
-        Connection con = DBManager.getConnection();
+    public ItemDAO() throws ItemException {
         try {
+            InitialContext ctx = new InitialContext();
+            ds = (DataSource) ctx.lookup("java:comp/env/jdbc/InventoryDS");
+        } catch (NamingException e) {
+            throw new ItemException(e);
+        }
+    }
 
-            PreparedStatement pStmt = con.prepareStatement("SELECT i.item_id as item_id,
i.item_name as item_name, i.description as description, im.quantity as quantity FROM item
i, item_master im WHERE im.item_id = i.item_id");
-            ResultSet rs = pStmt.executeQuery();
-            int j = 0;
-            while (rs.next()) {
-                ArrayList item = new ArrayList();
-
-                String itemId = rs.getString("item_id");
-                String itemName = rs.getString("item_name");
-                String description = rs.getString("description");
-                int quantity = rs.getInt("quantity");
-
-                item.add(0, itemId);
-                item.add(1, itemName);
-                item.add(2, description);
-                item.add(3, quantity + "");
+    public List<Item> getItems() throws ItemException {
+        ArrayList<Item> items = new ArrayList<Item>();
 
-                items.add(j, item);
-                j++;
+        try {
+            Connection con = ds.getConnection();
+            try {
 
-            }
-        } catch (SQLException e) {
-            e.printStackTrace();
-        } finally {
-            if (con != null) {
+                PreparedStatement pStmt = con.prepareStatement("SELECT i.item_id as item_id,
i.item_name as item_name, i.description as description, im.quantity as quantity FROM item
i, item_master im WHERE im.item_id = i.item_id");
                 try {
-                    con.close();
-                } catch (SQLException e) {
-                    e.printStackTrace();
+                    ResultSet rs = pStmt.executeQuery();
+                    try {
+                        while (rs.next()) {
+                            Item item = new Item();
+
+                            item.setItemNo(rs.getString("item_id"));
+                            item.setItemName(rs.getString("item_name"));
+                            item.setDescription(rs.getString("description"));
+                            item.setQuantity(rs.getInt("quantity"));
+
+
+                            items.add(item);
+                        }
+                    } finally {
+                        rs.close();
+                    }
+                } finally {
+                    pStmt.close();
                 }
+
+            } finally {
+                con.close();
             }
+        } catch (SQLException e) {
+            throw new ItemException(e);
         }
 
         return items;
     }
 
-    public int getQOH(String itemNo) {
+    public int getQOH(String itemNo) throws ItemException {
 
         int qoh = 0;
-        Connection con = DBManager.getConnection();
         try {
+            Connection con = ds.getConnection();
+            try {
 
-            PreparedStatement pStmt = con.prepareStatement("SELECT quantity FROM item_master
WHERE item_id =? ");
-            pStmt.setString(1, itemNo);
-
-            ResultSet rs = pStmt.executeQuery();
-            while (rs.next()) {
-                qoh = rs.getInt("quantity");
-            }
-        } catch (SQLException e) {
-            e.printStackTrace();
-        } finally {
-            if (con != null) {
+                PreparedStatement pStmt = con.prepareStatement("SELECT quantity FROM item_master
WHERE item_id =? ");
                 try {
-                    con.close();
-                } catch (SQLException e) {
-                    e.printStackTrace();
+                    pStmt.setString(1, itemNo);
+
+                    ResultSet rs = pStmt.executeQuery();
+                    try {
+                        if (rs.next()) {
+                            qoh = rs.getInt("quantity");
+                        }
+                    } finally {
+                        rs.close();
+                    }
+                } finally {
+                    pStmt.close();
                 }
+            } finally {
+                con.close();
             }
+        } catch (SQLException e) {
+            throw new ItemException(e);
         }
         return qoh;
     }
 
-    public boolean isItemIdExists(String itemNo) {
+    public boolean isItemIdExists(String itemNo) throws ItemException {
         boolean isExists = false;
-        Connection con = DBManager.getConnection();
         try {
+            Connection con = ds.getConnection();
+            try {
 
-            PreparedStatement pStmt = con.prepareStatement("SELECT item_id FROM item WHERE
item_id =? ");
-            pStmt.setString(1, itemNo);
-
-            ResultSet rs = pStmt.executeQuery();
-            if (rs.next()) {
-                isExists = true;
-            }
-        } catch (SQLException e) {
-            e.printStackTrace();
-        } finally {
-            if (con != null) {
+                PreparedStatement pStmt = con.prepareStatement("SELECT item_id FROM item
WHERE item_id =? ");
                 try {
-                    con.close();
-                } catch (SQLException e) {
-                    e.printStackTrace();
+                    pStmt.setString(1, itemNo);
+
+                    ResultSet rs = pStmt.executeQuery();
+                    try {
+                        if (rs.next()) {
+                            isExists = true;
+                        }
+                    } finally {
+                        rs.close();
+                    }
+                } finally {
+                    pStmt.close();
                 }
+            } finally {
+                con.close();
             }
+        } catch (SQLException e) {
+            throw new ItemException(e);
         }
         return isExists;
     }
 
-    public void updateQOH(String itemNo, int qoh) {
-        Connection con = DBManager.getConnection();
+    public void updateQOH(String itemNo, int qoh) throws ItemException {
         try {
+            Connection con = ds.getConnection();
+            try {
 
-            PreparedStatement pStmt = con.prepareStatement("UPDATE item_master SET quantity=?
WHERE item_id=?");
-            pStmt.setInt(1, qoh);
-            pStmt.setString(2, itemNo);
-
-            pStmt.executeUpdate();
-        } catch (SQLException e) {
-            e.printStackTrace();
-        } finally {
-            if (con != null) {
+                PreparedStatement pStmt = con.prepareStatement("UPDATE item_master SET quantity=?
WHERE item_id=?");
                 try {
-                    con.close();
-                } catch (SQLException e) {
-                    e.printStackTrace();
+                    pStmt.setInt(1, qoh);
+                    pStmt.setString(2, itemNo);
+
+                    pStmt.executeUpdate();
+                } finally {
+                    pStmt.close();
                 }
+            } finally {
+                con.close();
             }
+        } catch (SQLException e) {
+            throw new ItemException(e);
         }
-
     }
 
-    public void addItem(Item item) {
-        Connection con = DBManager.getConnection();
+    public void addItem(Item item) throws ItemException {
         try {
+            Connection con = ds.getConnection();
+            try {
 
-            PreparedStatement pStmt = con.prepareStatement("INSERT INTO item VALUES(?, ?,
?)");
-            pStmt.setString(1, item.getItemNo());
-            pStmt.setString(2, item.getItemName());
-            pStmt.setString(3, item.getDescription());
-
-            pStmt.executeUpdate();
-
-            pStmt = con.prepareStatement("INSERT INTO item_master VALUES(?, ?)");
-            pStmt.setString(1, item.getItemNo());
-            pStmt.setInt(2, 0);
-
-            pStmt.executeUpdate();
-
-        } catch (SQLException e) {
-            e.printStackTrace();
-        } finally {
-            if (con != null) {
+                PreparedStatement pStmt = con.prepareStatement("INSERT INTO item VALUES(?,
?, ?)");
                 try {
-                    con.close();
-                } catch (SQLException e) {
-                    e.printStackTrace();
+                    pStmt.setString(1, item.getItemNo());
+                    pStmt.setString(2, item.getItemName());
+                    pStmt.setString(3, item.getDescription());
+
+                    pStmt.executeUpdate();
+
+                    pStmt = con.prepareStatement("INSERT INTO item_master VALUES(?, ?)");
+                    pStmt.setString(1, item.getItemNo());
+                    pStmt.setInt(2, 0);
+
+                    pStmt.executeUpdate();
+                } finally {
+                    pStmt.close();
                 }
+
+            } finally {
+                con.close();
             }
+        } catch (SQLException e) {
+            throw new ItemException(e);
         }
     }
 

Modified: geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/services/InventoryManager.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/services/InventoryManager.java?rev=667090&r1=667089&r2=667090&view=diff
==============================================================================
--- geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/services/InventoryManager.java
(original)
+++ geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/services/InventoryManager.java
Thu Jun 12 06:46:09 2008
@@ -23,16 +23,17 @@
 import org.apache.geronimo.samples.inventory.dao.ItemDAO;
 import org.apache.geronimo.samples.inventory.exception.DuplicateItemIdException;
 import org.apache.geronimo.samples.inventory.exception.NotSufficientQuantityException;
+import org.apache.geronimo.samples.inventory.exception.ItemException;
 
 
 public class InventoryManager {
 
-    public List getItems() {
+    public List<Item> getItems() throws ItemException {
         ItemDAO dao = new ItemDAO();
         return dao.getItems();
     }
 
-    public void issueItem(String itemNo, int quantity) throws NotSufficientQuantityException
{
+    public void issueItem(String itemNo, int quantity) throws NotSufficientQuantityException,
ItemException {
         ItemDAO dao = new ItemDAO();
 
         int qoh = dao.getQOH(itemNo);
@@ -42,7 +43,7 @@
         dao.updateQOH(itemNo, (qoh - quantity));
     }
 
-    public void recvItem(String itemNo, int quantity) {
+    public void recvItem(String itemNo, int quantity) throws ItemException {
         ItemDAO dao = new ItemDAO();
 
         int qoh = dao.getQOH(itemNo);
@@ -50,7 +51,7 @@
         dao.updateQOH(itemNo, (qoh + quantity));
     }
 
-    public void addItem(String itemNo, String itemName, String desc) throws DuplicateItemIdException
{
+    public void addItem(String itemNo, String itemName, String desc) throws DuplicateItemIdException,
ItemException {
         ItemDAO dao = new ItemDAO();
 
         if (dao.isItemIdExists(itemNo)) throw new DuplicateItemIdException();

Modified: geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/AddItemServlet.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/AddItemServlet.java?rev=667090&r1=667089&r2=667090&view=diff
==============================================================================
--- geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/AddItemServlet.java
(original)
+++ geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/AddItemServlet.java
Thu Jun 12 06:46:09 2008
@@ -25,6 +25,7 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.geronimo.samples.inventory.exception.DuplicateItemIdException;
+import org.apache.geronimo.samples.inventory.exception.ItemException;
 import org.apache.geronimo.samples.inventory.services.InventoryManager;
 
 
@@ -52,6 +53,9 @@
             } catch (DuplicateItemIdException e) {
                 req.setAttribute("error", "Duplicate Item Id");
                 getServletContext().getRequestDispatcher("/jsp/error.jsp").forward(req, res);
+            } catch (ItemException e) {
+                req.setAttribute("Internal error", e.getCause().getMessage());
+                getServletContext().getRequestDispatcher("/jsp/error.jsp").forward(req, res);
             }
         } else {
             String error = "";

Modified: geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/IssueingServlet.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/IssueingServlet.java?rev=667090&r1=667089&r2=667090&view=diff
==============================================================================
--- geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/IssueingServlet.java
(original)
+++ geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/IssueingServlet.java
Thu Jun 12 06:46:09 2008
@@ -25,6 +25,7 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.geronimo.samples.inventory.exception.NotSufficientQuantityException;
+import org.apache.geronimo.samples.inventory.exception.ItemException;
 import org.apache.geronimo.samples.inventory.services.InventoryManager;
 
 
@@ -56,6 +57,9 @@
         } catch (NotSufficientQuantityException e) {
             req.setAttribute("error", "Not Sufficient Qunatity to Issue Items");
             getServletContext().getRequestDispatcher("/jsp/error.jsp").forward(req, res);
+        } catch (ItemException e) {
+            req.setAttribute("Internal error", e.getCause().getMessage());
+            getServletContext().getRequestDispatcher("/jsp/error.jsp").forward(req, res);
         }
     }
 

Modified: geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/jsp/issue.jsp
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/jsp/issue.jsp?rev=667090&r1=667089&r2=667090&view=diff
==============================================================================
--- geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/jsp/issue.jsp
(original)
+++ geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/jsp/issue.jsp
Thu Jun 12 06:46:09 2008
@@ -17,6 +17,7 @@
 under the License.
 -->
 <%@ page import="java.util.List" %>
+<%@ page import="org.apache.geronimo.samples.inventory.Item" %>
 
 <HTML>
 <jsp:useBean id="inventoryManager" scope="session" class="org.apache.geronimo.samples.inventory.services.InventoryManager"/>
@@ -32,12 +33,12 @@
                 <TD>
                     <SELECT name="item_no">
                         <%
-                            List itemList = inventoryManager.getItems();
+                            List<Item> itemList = inventoryManager.getItems();
                             for (int i = 0; i < itemList.size(); i++) {
-                                List item = (List) itemList.get(i);
+                                Item item = itemList.get(i);
 
-                                String itemNo = (String) item.get(0);
-                                String itemName = (String) item.get(1);
+                                String itemNo = item.getItemNo();
+                                String itemName = item.getItemName();
                         %>
                         <OPTION value="<%=itemNo%>"><%=itemName%>
                         </OPTION>

Modified: geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/jsp/recv.jsp
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/jsp/recv.jsp?rev=667090&r1=667089&r2=667090&view=diff
==============================================================================
--- geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/jsp/recv.jsp
(original)
+++ geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/jsp/recv.jsp
Thu Jun 12 06:46:09 2008
@@ -17,13 +17,14 @@
 under the License.
 -->
 <%@ page import="java.util.List" %>
+<%@ page import="org.apache.geronimo.samples.inventory.Item" %>
 
 <HTML>
 <jsp:useBean id="inventoryManager" scope="session" class="org.apache.geronimo.samples.inventory.services.InventoryManager"/>
 <HEAD><TITLE>Receiving</TITLE></HEAD>
 <BODY>
 <div align="center">
-    <H2>Recieving of Goods</H2>
+    <H2>Receiving of Goods</H2>
 
     <FORM method="POST" action="../recv">
         <TABLE bgcolor="cyan">
@@ -32,12 +33,12 @@
                 <TD>
                     <SELECT name="item_no">
                         <%
-                            List itemList = inventoryManager.getItems();
+                            List<Item> itemList = inventoryManager.getItems();
                             for (int i = 0; i < itemList.size(); i++) {
-                                List item = (List) itemList.get(i);
+                                Item item = itemList.get(i);
 
-                                String itemNo = (String) item.get(0);
-                                String itemName = (String) item.get(1);
+                                String itemNo = item.getItemNo();
+                                String itemName = item.getItemName();
                         %>
                         <OPTION value="<%=itemNo%>"><%=itemName%>
                         </OPTION>

Modified: geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/welcome.jsp
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/welcome.jsp?rev=667090&r1=667089&r2=667090&view=diff
==============================================================================
--- geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/welcome.jsp
(original)
+++ geronimo/samples/branches/2.1/samples/inventory/inventory-war/src/main/webapp/welcome.jsp
Thu Jun 12 06:46:09 2008
@@ -17,6 +17,8 @@
 under the License.
 -->
 <%@ page import="java.util.List" %>
+<%@ page import="org.apache.geronimo.samples.inventory.Item" %>
+<%@ page import="org.apache.geronimo.samples.inventory.exception.ItemException" %>
 
 
 <HTML>
@@ -24,10 +26,11 @@
 <HEAD><TITLE>Welcome</TITLE></HEAD>
 <BODY>
 <div div=true align="center">
-    <strong><H2>Welcome to the Inventory Contorl System</H2><br><br><br></strong>
+    <strong><H2>Welcome to the Inventory Control System</H2><br><br><br></strong>
 
     <%
-        List itemList = inventoryManager.getItems();
+        try {
+        List<Item> itemList = inventoryManager.getItems();
         if (itemList.size() > 0) {
 
     %>
@@ -40,12 +43,12 @@
         </TR>
         <%
             for (int i = 0; i < itemList.size(); i++) {
-                List item = (List) itemList.get(i);
+                Item item = itemList.get(i);
 
-                String itemNo = (String) item.get(0);
-                String itemName = (String) item.get(1);
-                String description = (String) item.get(2);
-                String quantity = (String) item.get(3);
+                String itemNo = item.getItemNo();
+                String itemName = item.getItemName();
+                String description = item.getDescription();
+                String quantity = "quantity: " + item.getQuantity();
         %>
         <TR>
             <TD><%=itemNo%>
@@ -57,15 +60,18 @@
             <TD><%=quantity%>
             </TD>
         </TR>
-        <% }%>
+        <%}%>
     </TABLE>
-    <%}%>
+    <% }
+    } catch (ItemException e) { %>
+        Error: <%=e.getMessage()%>    
+    <% }%>
     <br>
     <br>
     <TABLE>
         <TR>
             <TD><A href="jsp/add.jsp">Add Items </A></TD>
-            <TD><A href="jsp/recv.jsp">Recieving</A></TD>
+            <TD><A href="jsp/recv.jsp">Receiving</A></TD>
             <TD><A href="jsp/issue.jsp">Issueing</A></TD>
         </TR>
     </TABLE>



Mime
View raw message