Using the Struts Framework to Develop a Message Board--Part 2: Developing the Model for the Message Board
- Using the Struts Framework to Develop a Message Board--Part 2: Developing the Model for the Message Board
- Message
- MessageBoard
As described in the previous article, ActionForm classes that are conformant with the Struts framework need to be developed for every entity involved in the application.
Identity
The Identity class represents the user who’s involved in the application. When the user has been identified with a name and email, this identity is used when the user creates new messages. Identity is a simplistic class containing input/output properties for each attribute, as shown in Listing 1. It implements ActionForm as necessitated by the Struts framework.
Listing 1 Identity.java—Class Representing the User
import org.apache.struts.action.ActionForm; public class Identity implements ActionForm { protected String name; protected String email; public void setName(String name) { this.name = name; } public void setEmail(String email) { this.email = email; } public String getName() { return name; } public String getEmail() { return email; } public String toString() { return ("Name: " + getName() + " Email: " + getEmail()); } }