KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > exomvc > pojo > ListUserPage


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portlets.exomvc.pojo;
6
7 import java.io.IOException JavaDoc;
8 import java.util.List JavaDoc;
9 import javax.portlet.ActionRequest;
10 import javax.portlet.ActionResponse;
11 import javax.portlet.RenderRequest;
12 import javax.portlet.RenderResponse;
13 import org.exoplatform.commons.utils.PageList;
14 import org.exoplatform.commons.xhtml.Attributes ;
15 import org.exoplatform.container.PortalContainer;
16 import org.exoplatform.portlet.exomvc.Page;
17 import org.exoplatform.portlet.exomvc.XHTMLBuilder;
18 import org.exoplatform.services.organization.OrganizationService;
19 import org.exoplatform.services.organization.User;
20
21 public class ListUserPage extends Page {
22   static private Attributes USER_TABLE_ATTRS = new Attributes("border:1|width:100%") ;
23   
24   public void processAction(ActionRequest req, ActionResponse res) {
25  
26   }
27   
28   public void render(RenderRequest req, RenderResponse res) throws Exception JavaDoc {
29     PortalContainer container = PortalContainer.getInstance() ;
30     OrganizationService orgService =
31       (OrganizationService)container.getComponentInstanceOfType(OrganizationService.class) ;
32     PageList pageList = orgService.getUserPageList(15) ; // 15 users per page
33
//List page = pageList.currentPage() ; //get current use in page 1
34
List JavaDoc all = pageList.getAll() ; // get all users in db
35
ListUserBuilder builder = new ListUserBuilder(res, this) ;
36     builder.
37       startTABLE(USER_TABLE_ATTRS).
38         startTR().
39           startTH().text("User Name").closeTH().
40           startTH().text("First Name").closeTH().
41           startTH().text("Last Name").closeTH().
42           startTH().text("Email").closeTH().
43         closeTR();
44         builder.createUsersBlock(all).
45       closeTABLE() ;
46   }
47   
48   static public class ListUserBuilder extends XHTMLBuilder {
49     public ListUserBuilder(RenderResponse res, Page page) throws Exception JavaDoc {
50       super(res, page) ;
51     }
52
53     public ListUserBuilder createUsersBlock(List JavaDoc users) throws IOException JavaDoc {
54       for (int i =0; i < users.size(); i++) {
55         User user = (User) users.get(i) ;
56         startTR().
57           TD(user.getUserName()).
58           TD(user.getFirstName()).
59           TD(user.getLastName()).
60           TD(user.getEmail()).
61         closeTR();
62       }
63       return this ;
64     }
65   }
66 }
Popular Tags