Java Reference
In-Depth Information
all of its replies. This new link also passes through the parent so that the user
will not need to type it.
Building the model, view, and controller for ShowThread
For our purposes, a board displays a collection of threads, and a thread dis-
plays a collection of posts. This controller will serve a list of posts. In the next
listings, we establish a controller, command, and JSP triangle to show a thread.
This triangle, given a parent ID , will display a post and all of its replies.
The model wrapper for ShowThread
First, here is the command:
package bbs;
import java.sql.*;
import java.util.*;
public class ShowThreadCommand {
private static final int SUBJECT_COLUMN = 1;
private static final int AUTHOR_COLUMN = 2;
private static final int BOARD_COLUMN = 3;
private static final int POSTTEXT_COLUMN = 4;
private static final int NUMBER_COLUMN = 5;
The imports are the same as postList . We have column definitions for all of
our main database columns so that we can descriptively refer to each of the
columns in the select statement:
protected Vector author = new Vector();
protected Vector subject = new Vector();
protected Vector board = new Vector();
private Vector postText = new Vector();
private String parent = "0";
private String query = null;
protected ResultSet result;
protected Connection connection = null;
public String getAuthor(int index) {
return (String) author.elementAt(index);
public String getBoard(int index) {
return (String) board.elementAt(index);
public String getParent() {
return parent;
Search WWH ::

Custom Search