1 5 package org.exoplatform.portlets.exomvc.pojo; 6 7 import java.io.IOException ; 8 import java.util.List ; 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 { 29 PortalContainer container = PortalContainer.getInstance() ; 30 OrganizationService orgService = 31 (OrganizationService)container.getComponentInstanceOfType(OrganizationService.class) ; 32 PageList pageList = orgService.getUserPageList(15) ; List all = pageList.getAll() ; 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 { 50 super(res, page) ; 51 } 52 53 public ListUserBuilder createUsersBlock(List users) throws IOException { 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 |