KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > j2biz > blogunity > web > decorator > EntriesTableDecorator


1 /*
2  * $Id: EntriesTableDecorator.java,v 1.4 2005/01/10 03:12:56 keyboardsamurai Exp $
3  *
4  * Copyright (c) 2004 j2biz Group, http://www.j2biz.com Koeln / Duesseldorf ,
5  * Germany
6  *
7  * @author Max Kalina
8  *
9  *
10  * This program is free software; you can redistribute it and/or modify it under
11  * the terms of the GNU General Public License as published by the Free Software
12  * Foundation; either version 2 of the License, or (at your option) any later
13  * version.
14  *
15  * This program is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License along with
21  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22  * Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */

25
26 package com.j2biz.blogunity.web.decorator;
27
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30
31 import com.j2biz.blogunity.pojo.Entry;
32
33 public class EntriesTableDecorator extends AbstractTableDecorator {
34     /**
35      * Logger for this class
36      */

37     private static final Log log = LogFactory.getLog(EntriesTableDecorator.class);
38     
39     public String JavaDoc getAuthor() {
40
41         Entry entry = (Entry) getCurrentRowObject();
42         return utils.renderUser(entry.getAuthor(), request);
43     }
44
45     public String JavaDoc getEntry() {
46
47         Entry entry = (Entry) getCurrentRowObject();
48         return utils.renderEntry(entry, request);
49     }
50
51     public String JavaDoc getCreateTime() {
52
53         Entry entry = (Entry) getCurrentRowObject();
54         return utils.formatDateTime(entry.getCreateTime());
55     }
56
57     public String JavaDoc getType() {
58
59         Entry entry = (Entry) getCurrentRowObject();
60         if (entry.getType() == Entry.DRAFT) return "DRAFT";
61         else if (entry.getType() == Entry.PRIVATE) return "PRIVATE";
62         else
63             return "PUBLIC";
64     }
65
66     public String JavaDoc getActions() {
67
68         Entry entry = (Entry) getCurrentRowObject();
69         StringBuffer JavaDoc out = new StringBuffer JavaDoc();
70         out.append("<nobr>");
71
72         // edit link
73
out.append("<a HREF=\"");
74         out.append(ctx);
75         out.append("/my/editEntryForm?id=");
76         out.append(entry.getId());
77         out.append("\">");
78         out.append(getMessageForKey("EDIT"));
79         out.append("</a>");
80         out.append("&nbsp;|&nbsp;");
81
82         // delete link
83
out.append("<a HREF=\"");
84         out.append(ctx);
85         out.append("/my/deleteBlogEntryConfirm?id=");
86         out.append(entry.getId());
87         out.append("\">");
88         out.append(getMessageForKey("DELETE"));
89         out.append("</a>");
90         out.append("&nbsp;|&nbsp;");
91
92         // comments link
93
out.append("<a HREF=\"");
94         out.append(ctx);
95         out.append("/my/listEntryComments?id=");
96         out.append(entry.getId());
97         out.append("\">");
98         out.append(getMessageForKey("COMMENTS"));
99         out.append("</a>");
100         out.append("&nbsp;|&nbsp;");
101         
102         // trackbacks link
103
out.append("<a HREF=\"");
104         out.append(ctx);
105         out.append("/my/listTrackbacks?id=");
106         out.append(entry.getId());
107         out.append("\">");
108         out.append(getMessageForKey("TRACKBACKS"));
109         out.append("</a>");
110         
111         out.append("</nobr>");
112
113         return out.toString();
114     }
115
116 }
Popular Tags