KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > modules > admin > users > UserListCellRenderer


1 /*
2 Copyright (c) 2003 eInnovation Inc. All rights reserved
3
4 This library is free software; you can redistribute it and/or modify it under the terms
5 of the GNU Lesser General Public License as published by the Free Software Foundation;
6 either version 2.1 of the License, or (at your option) any later version.
7
8 This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the GNU Lesser General Public License for more details.
11 */

12
13 package com.openedit.modules.admin.users;
14
15 import org.dom4j.DocumentFactory;
16 import org.dom4j.Element;
17 import org.dom4j.Namespace;
18 import org.dom4j.QName;
19
20 import com.openedit.users.User;
21 import com.openedit.webui.list.WebList;
22 import com.openedit.webui.list.WebListCellRenderer;
23
24
25 /**
26  * This renderer renders <code>{@link User}</code>s.
27  *
28  * @author Eric Galluzzo
29  */

30 public class UserListCellRenderer implements WebListCellRenderer
31 {
32     public static final Namespace USER_NAMESPACE = DocumentFactory.getInstance().createNamespace(
33             "user", "http://www.wspublisher.com/xmlns/User");
34     public static final QName USER_QNAME = DocumentFactory.getInstance().createQName(
35             "user", USER_NAMESPACE);
36     public static final QName USER_NAME_QNAME = DocumentFactory.getInstance().createQName(
37             "userName", USER_NAMESPACE);
38
39     /**
40      * Constructor for UserListCellRenderer.
41      */

42     public UserListCellRenderer()
43     {
44         super();
45     }
46
47     /* (non-Javadoc)
48      * @see WebListCellRenderer#getListCellElement(WebList, Object, DocumentFactory)
49      */

50     public Element getListCellElement(WebList inList, Object JavaDoc inValue, DocumentFactory inFactory)
51     {
52         Element elem = inFactory.createElement(USER_QNAME);
53         User user = (User) inValue;
54         Element userNameElem = DocumentFactory.getInstance().createElement(USER_NAME_QNAME);
55         userNameElem.setText(user.getUserName());
56         elem.add(userNameElem);
57
58         return elem;
59     }
60 }
61
Popular Tags