001: package pygmy.nntp.http;
002:
003: import pygmy.core.HttpRequest;
004:
005: import java.io.IOException;
006:
007: import pygmy.nntp.NewsGroup;
008:
009: public class PostView extends View {
010: NewsGroup topic;
011: ForumMessage message;
012:
013: public PostView(String urlPrefix, NewsGroup topic,
014: ForumMessage aMessage) {
015: super (urlPrefix);
016: this .topic = topic;
017: this .message = aMessage;
018: }
019:
020: public String render(HttpRequest request) throws IOException {
021: buffer.append("<div class=\"box2\">");
022: buffer
023: .append("<table width=\"100%\" cellspacing=\"0\" cellpadding=\"3\" border=\"0\" >\n");
024: startPost();
025: addHeader();
026: addContents();
027: // todo replace with template file.
028: buffer.append("</table>\n");
029: buffer.append("</div>\n");
030: return buffer.toString();
031:
032: }
033:
034: private void addContents() {
035: addTableRow("fileentry");
036: buffer.append("<td>\n");
037: buffer
038: .append("<textarea name=\"contents\" cols=\"80\" rows=\"20\">");
039: if (message != null) {
040: buffer.append(message.getContents());
041: }
042: buffer.append("</textarea>\n<br>");
043: buffer
044: .append("<input type=\"submit\" name=\"preview\" value=\"Preview\"> ");
045: buffer
046: .append("<input type=\"submit\" name=\"submit\" value=\"Post Message\"> ");
047: buffer.append("</td>\n");
048: tableRowEnd();
049: buffer.append("</form>\n");
050: }
051:
052: private void startPost() {
053: buffer.append("<form action=\"");
054: buffer.append(getForumUrl("/post"));
055: buffer.append("\" method=\"post\" name=\"messageForm\">\n");
056: // createHiddenField( "topic", topic.getGuid() );
057: if (message != null && message.getParentGuid() != null) {
058: createHiddenField("message", message.getParentGuid());
059: }
060: addTableRow("navigationbar");
061: buffer.append("\n<td nowrap align=\"left\">");
062: buffer.append("<font size=\"+1\" class=\"title\">");
063: if (message != null) {
064: buffer.append(message.getSubject());
065: } else {
066: buffer.append("Post a Message");
067: }
068: buffer.append("</font>");
069: buffer.append("</td>\n");
070: tableRowEnd();
071: }
072:
073: private void addHeader() {
074: addTableRow("tableheader");
075: buffer.append("<td>\n");
076:
077: buffer.append("<table>\n");
078: buffer.append("<tr>\n");
079: buffer.append("\n<td>\n<b>Subject:</b></td>\n");
080: buffer.append("<td>");
081: if (message != null) {
082: createTextField("subject", message.getSubject(), 60);
083: } else {
084: createTextField("subject", "", 60);
085: }
086: buffer.append("</td>\n");
087: tableRowEnd();
088:
089: buffer.append("<tr>\n");
090: buffer.append("\n<td><b>Author:</b></td>\n");
091: buffer.append("<td>");
092: if (message != null) {
093: createTextField("author", message.getAuthor(), 60);
094: } else {
095: createTextField("author", null, 60);
096: }
097: buffer.append("</td>\n");
098: tableRowEnd();
099: buffer.append("</table>\n");
100:
101: buffer.append("</td>\n");
102: tableRowEnd();
103: }
104:
105: }
|