Home > Articles > Programming > Java

Using the Struts Framework to Develop a Message Board--Part 2: Developing the Model for the Message Board

📄 Contents

  1. Using the Struts Framework to Develop a Message Board--Part 2: Developing the Model for the Message Board
  2. Message
  3. MessageBoard
  • Print
  • + Share This
In this seven-part series, Java expert Maneesh Sahu explores how to use Apache Software Foundation's Struts framework to develop a Web-based message board.
From the author of

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());
    }
}
  • + Share This
  • 🔖 Save To Your Account