FileDocCategorySizeDatePackage
PostMsgRenderer.javaAPI DocExample3134Sun Sep 02 14:59:04 BST 2001com.oreilly.forum.servlet

PostMsgRenderer

public class PostMsgRenderer extends Renderer
Show the web page that allows a user to post or reply to a message.

Fields Summary
private MessageSummary
inResponseToMsg
private BoardSummary
board
private String
msgSubject
private String
authorEmail
private String
msgText
private boolean
showError
Constructors Summary
public PostMsgRenderer(Message inResponseToMsg)
This constructor indicates that the user is replying to an existing message.

        this.board = inResponseToMsg.getBoard();
        this.inResponseToMsg = inResponseToMsg;
        this.showError = false;
        this.msgSubject = "Re: " + inResponseToMsg.getSubject();
        this.authorEmail = "";

        StringTokenizer st = new StringTokenizer(
                inResponseToMsg.getText(), "\n");
        StringBuffer buf = new StringBuffer();
        buf.append("\n");
        buf.append("\n> -----Original Message-----");
        buf.append("\n>   Posted by ");
        buf.append(inResponseToMsg.getAuthorEmail());
        buf.append(" on ");
        buf.append(inResponseToMsg.getCreateDate().toString());
        buf.append("\n");
        while (st.hasMoreTokens()) {
            String curLine = st.nextToken();
            buf.append("> ");
            buf.append(curLine);
            buf.append("\n");
        }
        buf.append("> ");
        this.msgText = buf.toString();
    
public PostMsgRenderer(BoardSummary board)
This constructor indicates that the user is posting a new message.

        this(board, null, false, "", "", "");
    
public PostMsgRenderer(BoardSummary board, MessageSummary inResponseToMsg, boolean showError, String msgSubject, String authorEmail, String msgText)
This constructor is used when the user submitted a form but did not fill out all required fields.

        this.board = board;
        this.inResponseToMsg = inResponseToMsg;
        this.showError = showError;
        this.msgSubject = msgSubject;
        this.authorEmail = authorEmail;
        this.msgText = msgText;
    
Methods Summary
public voidrender(javax.servlet.http.HttpServlet servlet, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)


        // convert the data into XML (a JDOM Document)
        Document doc = new Document(PostMessageJDOM.produceElement(
                this.board,
                this.inResponseToMsg,
                this.showError,
                this.msgSubject,
                this.authorEmail,
                this.msgText));

        // apply the appropriate stylesheet
        XSLTRenderHelper.render(servlet, doc, "postMsg.xslt", response);