Java
  Home arrow Java arrow Online Store Application
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Online Store Application
By: McGraw-Hill/Osborne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 19
    2005-03-16

    Table of Contents:
  • Online Store Application
  • Understanding the Page Control Flow
  • Structuring the Database Tables
  • The DatabaseUtil Class
  • The MenuBean Class
  • The ShoppingItemBean Class
  • Registering the Beans in the Application Configuration File
  • Adding the ActionListener
  • Creating the JSP Pages
  • The search.jsp Page
  • The shoppingCart.jsp Page

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    Iron Speed
     
    ADVERTISEMENT

    Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!

    Online Store Application


    (Page 1 of 11 )

    If you want to build an online store application using Java, look no further. This article begins with an overview of the application, and then discusses the applicatin development process. It is taken from chapter 14 of JavaServer Faces Programming by Budi Kurniawan (McGraw-Hill, 2003; ISBN 0072229837).

    In the previous chapters, you have learned the basics of JSF and how to build each component of a JSF application. To illustrate the use of JSF in the real world, this chapter presents an online store application named BuyDirect, an Internet store that sells electronic goods.

    This chapter begins with an overview of the application, and then discusses the application development process. We will cover page design, database design and access, model objects, the application configuration file entries for bean registration and navigation rules, the deployment descriptor, and the JSP pages.

    Introducing the BuyDirect Application

    The BuyDirect application allows users to do the following:

    • Search for certain products based on product names or descriptions.
    • Browse the list of products by category.
    • View a product’s details.
    • Add a product to the shopping cart.
    • View the shopping cart.
    • Check out and place an order.

    The main objective of this application is to show how to use JSF in a real-world application. Admittedly, the application is not a complete solution yet. For example, you cannot edit the shopping cart, and it lacks an administration section for changing the product information and handling the orders. However, it provides basic functionality, and finalizing it should not be difficult.

    The BuyDirect application has ten JSP pages, one ActionListener (AppActionListener), one context listener (AppContextListener), and eight JavaBeans. In addition, there are also the deployment descriptor and the JSF application configuration file, as well as a number of image files in the images directory. Figure 14-1 shows the directory structure of this application.


    Designing the Application Pages

    For consistency, each page in the BuyDirect application uses the same design. There is a header at the top of the page and a menu on the left side. The page template is shown in Figure 14-2.

    Here are the HTML tags that make up the page:

      <html>
      <head>
      <title><!-- The title --></title>
      </head>
      <body>
      <table>
      <tr>
        <td colspan="2">
        <!-- The header -->
      </td>
    </tr>
    <tr>
      <td valign="top">
        <!-- The menu -->
      </td>
      <td valign="top">
        <!-- Content -->
    </td>
    </tr>
    <tr>
      <td colspan="2">
        <!-- The footer -->
    </td>
    </tr>
    </table>
    </body>
    </html>


    Figure 14-1.  The BuyDirect application directory structure 


    Figure 14-2.  The BuyDirect application page design

    Using a Style Sheet

    Each page in the application links to a Cascading Style Sheet (CSS) file called Styles.css, residing in the application directory. Using a style sheet provides a more flexible way of formatting than embedding formatting directly on the page. The Styles.css file is shown in Listing 14-1.

    Listing 14-1 The Styles.css File

    body {
      background:#ffffff;
      font-family: verdana;
      font-size: 8pt;
      font-weight: bold;
      color: #000000;
    } A:link {
      font-family: verdana;
      font-size: 8pt;
      color: #000000;
      text-decoration:underline
    } A:visited {
      font-family: verdana;
      font-size: 8pt;
      color: #000000;
      text-decoration:underline
    }

    A:hover {
      font-family: verdana;
      font-size: 8pt;
      color: #CCCCCC;
      text-decoration:none
    }

    .Header {
      background: #CCCCCC;
      color: #FFFFFF;
    }

    .HeaderText1 {
      font-family: verdana;
      font-size: 13pt;
      font-weight: bold;
    }

    .HeaderText2 {
      font-family: verdana;
      font-size: 11pt;
      font-weight: bold;
    }

    .MenuHeader {
      font-family: verdana;
      font-size: 12pt;
      font-weight: bold;
      background: #CCCCCC;
      color: #FFFFFF;
    }

    .MenuItem:link {
      font-family: verdana;
      font-size: 8pt;
      font-weight: bold;
      color: #000000;
      text-decoration:none
    }

    .MenuItem:visited {
      font-family: verdana;
      font-size: 8pt;
      font-weight: bold;
      color: #000000;
      text-decoration:none
    }

    .MenuItem:hover {
      font-family: verdana;
      font-size: 8pt;
      font-weight: bold;
      color: #bbccdd;
      text-decoration:none
    }

    .OuterTable {
      background:#CCCCCC;
    }

    .InnerTable {
    background:#EDEDED;
    }

    .PageHeader {
      font-family: verdana;
      font-size: 16pt;
      font-weight: bold;
      color: #CCCCCC;
    }

    .SecondPageHeader {
      font-family: verdana;
      font-size: 14pt;
      font-weight: bold;
      color: #CCCCCC;
    }

    .TableHeader {
      font-family: verdana;
      font-size: 12pt;
      font-weight: bold;
      color: #FFFFFF;
    }

    .TableItem {
      font-family: verdana;
      font-size: 9pt;
      color: #000000;
    }

    .AlternatingTableItem {
      font-family: verdana;
      font-size: 9pt;
      color: #000000;
    }

    .Footer {
      font-family: verdana;
      font-size: 8pt;
      color: #000000;
    }

    .NormalLarge {
      font-family: verdana;
      font-size: 11pt;
      font-weight: bold;
      color: #000000;
    }

    .NormalSmall {
      font-family: verdana;
      font-size: 10pt;
      color: #000000;
    }

    .ErrorMessage {
      font-family: verdana;
      font-size: 10pt;
      color: #FF0000;
    }


    This article is excerpted from JavaServer Faces Programming by Budi Kurniawan (McGraw-Hill, 2003; ISBN 0072229837). Check it out at your favorite bookstore today. Buy this book now.

    More Java Articles
    More By McGraw-Hill/Osborne


       · I go thru the online application, and I'm new to this topic, can anyone recreate...
     

    JAVA ARTICLES

    - Deploying Multiple Java Applets as One
    - Deploying Java Applets
    - Understanding Deployment Frameworks
    - Database Programming in Java Using JDBC
    - Extension Interfaces and SAX
    - Entities, Handlers and SAX
    - Advanced SAX
    - Conversions and Java Print Streams
    - Formatters and Java Print Streams
    - Java Print Streams
    - Wildcards, Arrays, and Generics in Java
    - Wildcards and Generic Methods in Java
    - Finishing the Project: Java Web Development ...
    - Generics and Limitations in Java
    - Getting Started with Java Web Development in...

    Iron Speed

    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway