Custom Components
The toolset provided by the Struts Framework will provide most of what we will need for the client and
presentation tiers, but we will need some additional components in the business and integration tiers, namely:
-
A database schema designed to store our information
-
SQL commands to manage our information
-
Data access and helper objects to fetch information from persistent storage (for example, DBMS)
We will cover each of these components in detail over the remainder of the chapter.
First Steps
Since the application is based on the Struts Framework, we will focus on what we have to add to an
application based on the Struts "blank application" template. We will not be reviewing the standard
Struts classes, configuration files, or tag extensions in detail, or how other prerequisites, like the JDBC
classes, work. This material is better covered elsewhere. For more about Struts, see Chapter 2. The
example application will also use a component-based design. See Chapter 1 for more about designing
applications with components.
It's usually helpful to start an application with storyboard pages. A storyboard depicts the application as
a series of static pages a "non-working" demo:
-
A storyboard gives us an idea of how the application will look to the user, how they will
interact with the data, and how navigation will flow from page to page
-
A storyboard does not tell us exactly what components we will need on the backend, but it
does tell us a lot about what the components will have to do
-
A storyboard does not help us define the underlying workflow, but it does demonstrate how
we might represent a workflow as a web application
Let's take a look at how we expect our pages to work when we are finished. We will keep the layout
very simple, so the code can be adapted for use in other web pages.
Storyboard
To realize our initial workflow, it looks like we will need four pages:
-
The Menu Page
To select operations and enter search phrases
-
The Entry Page
To enter new articles
-
The Article Page
To display articles in full
-
The List Page
To display a found set of articles
At the storyboard stage we are not interested in how these pages will be implemented.
We don't need to worry about the business logic of the application yet; rather we are
considering how the content is presented to the user.
The Menu Page
This is a simple menu that we can use to test the application. We can easily select a list of current articles,
posted in the last day, week, or month. The LATEST NEWS button displays the last ten articles posted. If
a user is looking for something specific, they can also search by title, author, or the article content:
All of these forms, buttons, or links will be implemented with custom tags, and so can be easily
integrated with your own application's look and feel.
The Entry Page
This page is the data entry form for our contributors to use:
If a contributor is not logged in the user is challenged for identification, and must provide a valid
username and password.
The List Page
This page lists our articles. The same page should be used for all types of searches, making the addition
of new selections easy:
The Article Page
article.jsp, the heart of the application, displays the full text of the article, along with the title and
author. The editing controls at the bottom will only display for authorized users. We do not have to
create two versions of the page the page intelligently renders the correct page for the user:
The EDIT button will display the entry page, so that the article can be revised and re-submitted. The
DELETE button marks the article so that it will not display on searches, and can be permanently
removed at a later date. These buttons only display to contributors, and will not be available to
anonymous visitors to the site.
Now that we understand what we expect our application do be able to do, it's time to start thinking
about how to implement this functionality beginning with how the content itself is to be stored.
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.
|