Book Image

Spring Web Flow 2 Web Development

By : Markus Stäuble, Sven Lüppken
Book Image

Spring Web Flow 2 Web Development

By: Markus Stäuble, Sven Lüppken

Overview of this book

<p>Many web applications need to take the user through a defined series of steps such as e-commerce checkouts or user registrations. Spring Web Flow works well for rich and flexible user interaction, additionally it helps you to describe the flow of websites in complex processes. Spring Web Flow 2 provides the perfect way to build these kinds of features, keeping them secure, reliable, and easy to maintain.<br /><br />This book provides a platform on which you can build your own applications and services. It gives detailed information on Spring basics and covers core topics involving testing, security, and so on. We develop a complete, robust web application using the latest version of Spring, where page navigation is done on-the-fly.<br /><br />This book teaches you how to work with Spring Web Flow. It covers both basic and advanced aspects and provides a detailed reference of the features Spring Web Flow. The book helps readers to extend the framework. <br /><br />The integration of Spring and Java Server Pages is clearly explained in the book. The book also explains the essential modules of the complete Spring framework stack and teaches how to manage the control flow of a Spring web application.<br /><br />The Spring Faces module will provide integration between Spring Web Flow and Java Server Faces (JSF). Testing, an important aspect of the software development process is covered towards the end; the question of how to test a Spring Web Flow application is answered.</p>
Table of Contents (14 chapters)
Spring Web Flow 2 Web Development
Credits
About the Authors
About the Reviewers
Preface
flow.trac:The Model for the Examples

Appendix A. flow.trac:The Model for the Examples

In the previous chapters, we used the model classes from our sample project with the name, flow.trac-core. This project provides classes which could be used to implement a simple bug tracker application. In this appendix, we want to give you a short overview of the mentioned model classes. With this information, it is possible to understand the usage of the classes in the examples of this book.

flow.trac

The flow.trac model is separated into three packages, which are shown in the following figure. The classes in the project, flow.trace.core, are independent of Spring Web Flow 2.

The classes defined in flow.trac.core are listed here.

Item

Each element, which can be stored into a database, is of type Item, is a simple marker interface.

An Item has some meta information which is enumerated as follows:

  • The date on which the item is created (Method: getCreationDate())

  • The date on which the item was last modified (Method: getLastModified())

  • The user who created the item (Method: getCreatedBy())

  • The user who has done the last modification on the item (Method: getLastModifiedBy())

Additionally, the interface Item extends the marker interface, java.io.Serializable.

User

There are users inside a bug tracker system. In our case, the users are represented as an instance from flowtrac.core.model.User.

For the User instance, it is worth mentioning that our examples use the name of the user as the identifier. Therefore, the username is unique in our examples.

Role

Each user has a role of type, flowtrac.core.model.user.Role. At the time of first contact with the system (the login mask) each user possesses the role, Anonymous. The role itself is modeled as an enumeration type. We have implemented the following five roles:

  • Anonymous

  • Guest

  • NamedUser

  • ProjectAdministrator

  • Administrator

Project

After a user is logged in, the role of the user changes to a NamedUser. Inside the bug tracker, an issue belongs to a project. The project is realized as an interface from the type, flowtrace.core.model.Project. The interface Project extends from flowtrac.core.model.Item.

Issue

The central element of the system is of the type Issue. This element contains all information about a bug or a requirement. The Issue is annotated with elements from the JPA (Java Persistence API) to store it into a relational database.

In the following listing, we show the complete implementation of the class flowtrac.core.model.issue.Issue.

package flowtrac.core.model.issue;
flow.trac.core, flow.trac modelflowtrac.core.model.issue.Issue class, implementingimport java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import flowtrac.core.model.Item;
import flowtrac.core.model.user.User;
@Entity
public class Issue implements Item {
/**
* Generated by eclipse.
*/
private static final long serialVersionUID = 5711325923341961421L;
private String name;
private String description;
private Long id;
private Date fixingDate;
private Date lastModifed;
private Date creationDate;
/**
* @see flowtrac.core.model.issue.Issue#getFixingDate()
*/
public Date getFixingDate() {
return this.fixingDate;
}
/**
flow.trac.core, flow.trac modelflowtrac.core.model.issue.Issue class, implementing* @see flowtrac.core.model.issue.Issue#getId()
*/
@Id
@GeneratedValue
public Long getId() {
return this.id;
}
/**
* @see flowtrac.core.model.issue.Issue#getName()
*/
public String getName() {
return this.name;
}
/**
* @see flowtrac.core.model.issue.Issue#setName(java.lang.String)
*/
public void setName(String name) {
this.name = name;
}
/**
* @see flowtrac.core.model.issue.Issue#setId(long)
*/
public void setId(long id) {
this.id = id;
}
/**
* @see flowtrac.core.model.issue.Issue#setFixingDate(java.util.Date)
*/
public void setFixingDate(Date fixingDate) {
this.fixingDate = fixingDate;
}
/* (non-Javadoc)
* @see flowtrac.core.model.issue.ItemInformation#getCreatedBy()
*/
public User getCreatedBy() {
// TODO Auto-generated method stub
return null;
}
/**
* @see flowtrac.core.model.issue.ItemInformation#getCreationDate()
*/
public Date getCreationDate() {
return this.creationDate;
}
/**
flow.trac.core, flow.trac modelflowtrac.core.model.issue.Issue class, implementing* @see flowtrac.core.model.issue.ItemInformation#getLastModified()
*/
public Date getLastModified() {
return this.lastModifed;
}
/* (non-Javadoc)
* @see flowtrac.core.model.issue .ItemInformation#getLastModifiedBy()
*/
public User getLastModifiedBy() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see flowtrac.core.model.issue.ItemInformation#setCreatedBy( flowtrac.core.model.user.User)
*/
public void setCreatedBy(User createdBy) {
// TODO Auto-generated method stub
}
/**
* @see flowtrac.core.model.issue. ItemInformation#setCreationDate(java.util.Date)
*/
public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}
/**
* @see flowtrac.core.model.issue. ItemInformation#setLastModified(java.util.Date)
*/
public void setLastModified(Date lastModified) {
this.lastModifed = lastModified;
}
/* (non-Javadoc)
flow.trac.core, flow.trac modelflowtrac.core.model.issue.Issue class, implementing* @see flowtrac.core.model.issue. ItemInformation#setLastModifiedBy(flowtrac.core.model.user.User)
*/
public void setLastModifiedBy(User lastModfiedBy) {
// TODO Auto-generated method stub
}
/**
* @see flowtrac.core.model.issue.Issue#getDescription()
*/
public String getDescription() {
return this.description;
}
/**
* @see flowtrac.core.model.issue. Issue#setDescription(java.lang.String)
*/
public void setDescription(final String description) {
this.description = description;
}
private Type type;
/**
* @return type type of the issue.
*/
public Type getType() {
return this.type;
}
public void setType(final Type type) {
this.type = type;
}
}

Type

An issue can have a Type. The type is encapsulated as enumeration. Currently, we have implemented the following three types:

  • Feature

  • Bug

  • Task

Priority

Each issue has a priority. The priority is encapsulated as enumeration. We have implemented the following three priorities:

  • Minor

  • Major

  • Critical

Comment

A user can enter a comment for an issue. A Comment is an Item and only consists of some text. An Issue can have more than one Comment.

Attachment

A user can attach one or more files to an issue. The attachment itself is encapsulated with the interface, Attachment.