Home Struts new Hot Jobs new

Free Downloads

 

 

 

Disclaimer: This is a bare-bones sample specification to illustrate building a Struts application. The format and detail provided by a specification varies from project to project. The specification for your project may look very different, but may still have these basic  elements in common. For more about writing project specifications and constructing software, see one of the many comprehensive texts on this topics, including Structured Analysis and Systems Specifications by Tom DeMarco (ISBN 0138543801) and Code Complete by Steve McConnell (ISBN 1556154844).

Example Application - Sample Specification 


1.0 Problem Definition

Many people have email accounts on various servers. Some email clients do not handle multiple accounts well. Private and public email portals and gateways usually allow accounts only on their own servers. 


2.0 Proposed Solution

These problems could be solved by a "portal" Web application that would allow users to register a set of email subscriptions for any Internet mail server, and then retrieve mail for these subscriptions. 


3. 0 Requirements

3.1 Core tasks

3.2 Other requirements


4.0 Sample Screen Flow

4.1 Welcome

4.2 Register

 Display form with registration properties; options to Save, Reset, and Cancel.

4.3 Login

Display form to login user account, with options to Save or Reset.

4.4 Menu

4.5 Account

4.6 Subscription - Add, Edit, Delete.

Display form with subscription properties; options appropriate to task (Add, Edit, Delete).

4.7 Logout

Invalidate user's login; return to Welcome screen.


5. 0 Product Selection

Java using the Struts Framework is selected for the project since


6.0 Application Program Interface

6.1 Properties

Label Bean Property Type Restrictions Domain
Username User username String !null unique
Password User password String !null  
Full Name User fullname String !null  

From Address

User fromAddress String !null *@*

Reply To Address

User replyToAddress String    
- User subscriptions Hashtable    

Mail Server

Subscription host String !null unique

Mail Username

Subscription username String !null  
Mail Password Subscription password String !null  
Mail Server Type Subscription type String   "imap","pop3"
Password (repeat) registrationForm password2 String !null  
           

6. 3 Form Beans

<form-beans>

<!-- Logon form bean -->
<form-bean name="logonForm"
type="org.apache.struts.example.LogonForm"/>

<!-- Registration form bean -->
<form-bean name="registrationForm"
type="org.apache.struts.example.RegistrationForm"/>

<!-- Subscription form bean -->
<form-bean name="subscriptionForm"
type="org.apache.struts.example.SubscriptionForm"/>

</form-beans>


6.4 Action Mappings

6.4.1 Example Mappings for Core Tasks
Create an account with a username and password

Log into account

Add email subscriptions

Edit subscription

Delete subscription

Logout

Pages that require account information must not be displayed to unauthorized users.
6.4.1 Actual Configuration

<action-mappings>

<!-- Process a user logon -->
<action path="/logon"
type="org.apache.struts.example.LogonAction"
name="logonForm"
scope="request"
input="/logon.jsp">
</action>

<!-- Edit user registration -->
<action path="/editRegistration"
type="org.apache.struts.example.EditRegistrationAction"
name="registrationForm"
scope="request"
validate="false">
<forward name="success" path="/registration.jsp"/>
</action>

<!-- Save user registration -->
<action path="/saveRegistration"
type="org.apache.struts.example.SaveRegistrationAction"
name="registrationForm"
scope="request"
input="/registration.jsp"/>

<!-- Edit mail subscription -->
<action path="/editSubscription"
type="org.apache.struts.example.EditSubscriptionAction"
name="subscriptionForm"
scope="request"
validate="false">
<forward name="failure" path="/mainMenu.jsp"/>
<forward name="success" path="/subscription.jsp"/>
</action>

<!-- Save mail subscription -->
<action path="/saveSubscription"
type="org.apache.struts.example.SaveSubscriptionAction"
name="subscriptionForm"
scope="request"
input="/subscription.jsp">
<forward name="success" path="/editRegistration.do?action=Edit"/>
</action>

<!-- Process a user logoff -->
<action path="/logoff"
type="org.apache.struts.example.LogoffAction">
<forward name="success" path="/index.jsp"/>
</action>

</action-mappings>


6.3 Custom Tags

6.3.1 Example Application Tags

This application uses the following custom tags with an app prefix:

App tags - <%@ taglib uri="/WEB-INF/app.tld" prefix="app" %>

Tag Name Description
CheckLogin Check for a valid User logged on in the current session. If there is no such user, forward control to the logon page.
LinkUser Generate a URL-encoded hyperlink to the specified URI, with associated query parameters selecting a specified User.
LinkSubscription Generate a URL-encoded hyperlink to the specified URI, with associated query parameters selecting a specified Subscription.

CheckLogin
Attribute Name Description
  No Attributes

LinkUser
Attribute Name Description
page Action to use with User key, for example "/editSubscription.do?action=Create".
This tag will then generate a hyperlink target that appends the key to the user's account. 
For example given a username of "user":
<a href="/struts-example/editSubscription.do?action=Create&username=user">

LinkSubscription 
Attribute Name Description
page Action to use with User and Subscription keys, for example "/editSubscription.do?action=Edit".
This tag will then generate a hyperlink target that appends the keys to the user and the subscription.
For example given a user with the name "user" and subscription with a host of "mail.yahoo.com"":
<a href="/struts-example/editSubscription.do?action=Edit&username=user&host=mail.yahoo.com">

6.3.2 Struts Custom Tags

With this application, the following Struts tags libraries and prefixes are used:

Bean tags - <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
HTML tags -  <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
Logic tags - <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>


6.4 Page Action Index

Page Beans Actions
index.jsp None

page="/editRegistration.do?action=Create"
page="/logon.jsp"

logon.jsp logonForm action="logon.do"
mainMenu.jsp user (session)

page=/editRegistration.do?action=Edit"
page="/logoff.do"

registration.jsp user (session)
registrationForm
action="saveRegistration.do"
page="/editSubscription.do?action=Delete"
page="/editSubscription.do?action=Edit"
page="/editSubscription.do?action=Create"
subscription.jsp user (session)
subscriptionForm
action="saveSubscription.do"

6.5 Internationalization

See < classes/org/apache/struts/example/ApplicationResource.properties >. 

This file includes all error messages and text used through the application. 

Additional languages can be supported by translating this file.

The application will automatically choose the language appropriate to a visitor's locale.


 

BACK TO STRUTS