KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: UsersTableDecorator.java,v 1.4 2004/12/26 00:26:18 michelson 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.User;
32
33 public class UsersTableDecorator extends AbstractTableDecorator {
34     /**
35      * Logger for this class
36      */

37     private static final Log log = LogFactory.getLog(UsersTableDecorator.class);
38
39     public String JavaDoc getNickname() {
40
41         User u = (User) getCurrentRowObject();
42         return utils.renderUser(u, request);
43     }
44
45     public String JavaDoc getRegisterTime() {
46         User u = (User) getCurrentRowObject();
47         return utils.formatDateTime(u.getRegisterTime());
48     }
49
50     public String JavaDoc getActions() {
51
52         User friend = (User) getCurrentRowObject();
53         StringBuffer JavaDoc out = new StringBuffer JavaDoc();
54         out.append("<nobr>");
55
56         // delete link
57
out.append("<a HREF=\"");
58         out.append(ctx);
59         out.append("/my/deleteFriendConfirm?id=");
60         out.append(friend.getId());
61         out.append("\">");
62         out.append(getMessageForKey("DELETE"));
63         out.append("</a>");
64
65         out.append("</nobr>");
66
67         return out.toString();
68     }
69
70     public String JavaDoc getAdminActions() {
71
72         User u = (User) getCurrentRowObject();
73         StringBuffer JavaDoc out = new StringBuffer JavaDoc();
74         out.append("<nobr>");
75
76         // edit link
77
out.append("<a HREF=\"");
78         out.append(ctx);
79         out.append("/my/editUserForm?id=");
80         out.append(u.getId());
81         out.append("\">");
82         out.append(getMessageForKey("EDIT"));
83         out.append("</a>");
84
85         // delete link
86
if (!u.isAdministrator()) {
87             out.append("&nbsp;|&nbsp;");
88             out.append("<a HREF=\"");
89             out.append(ctx);
90             out.append("/my/deleteUserConfirm?id=");
91             out.append(u.getId());
92             out.append("\">");
93             out.append(getMessageForKey("DELETE"));
94             out.append("</a>");
95         }
96
97         out.append("</nobr>");
98
99         return out.toString();
100     }
101
102 }
Popular Tags