Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Write your own threaded discussion forum

Use a forum to make your Web site more interactive, provide customer support, and more

  • Print
  • Feedback
Discussion forums are great for providing interactivity and the potential for message exchange. A simple Java-based forum tied to a Web site can offer site visitors ease of use and topical discussion capabilities. Let's build one!

Discussion group systems come in many flavors. The quintessential example of a full-featured discussion forum is Usenet, the Internet "news" network. Usenet is a client/server system consisting of a network of servers that supports tens of thousands of separate newsgroups. Each group contains multiple concurrent discussion topics. Each topic, or thread, contains multiple articles, linked as a series of responses to the first post in the topic. A single simple thread may remain a straight line or turn into a tree as people post follow-up messages to replies and so on.

Usenet users can read articles, post responses in threads, and start their own threads. They can even start their own groups, although that's a little more involved. New threads and articles propagate throughout the world's network of Usenet servers, and are available to anyone accessing the system.

With our Interchange forum applet, we plan to capture the core functionality of Usenet in a Java system, but in a far simpler fashion.

Design points

Feature overview

The discussion Forum we're going to build is the equivalent of one Usenet newsgroup, with a fixed set of threads provided by the site administrator. Users will have the option to read articles submitted under the available threads, post new articles, and reply to others' posts. The Forum administrator will have the option to age articles, limit memory and disk usage, and restrict access to designated portions of the Internet.

Let's get into specifics on how the client can implement its features.

User interface behavior

  • GUI
    The list of threads, the list of articles, a control area, and a display window should be the main features of the interface, since they are the most-used. It doesn't hurt to mirror control options on the menu bar as well, along with other less commonly-used features such as "Close."

  • Modes
    The client interface needs to reflect the current operation that the user is performing. A good way to do this is to make the client support four mutually exclusive modes: READ (text display area shows message text, post/reply button shows "reply"), REPLY (text display shows quoted message text, post/read button shows "post"), NEW (text area displays a blank message, post/read button shows "post"), and POST (id field will be shown if it needs to be filled out).

    The click of a button or selection of a menu item produces an event that performs appropriate actions, sets the client's internal mode, and determines the components showing on the interface.

  • User identity
    The user needs to be able to set and change his/her identity. The user's identity is used to "sign" articles, and is placed in the article list to represent posted articles.

    Selection of the identity option from the menu drives a layout change in which the control panel resizes to accommodate a TextField for identity entry. The identity TextField disappears when it has focus and the return key is pressed.

  • Print
  • Feedback

Resources