kimptoc     02/04/28 14:00:00

  Modified:    src/java/org/apache/jetspeed/modules/actions/portlets/security
                        UserBrowserAction.java
               webapp/WEB-INF/conf admin.xreg
               webapp/WEB-INF/templates/vm/portlets/html user-browser.vm
               webapp/css default.css
               xdocs    changes.xml
  Log:
  add paging through user browser
  
  Revision  Changes    Path
  1.6       +55 -2     
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/security/UserBrowserAction.java
  
  Index: UserBrowserAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/security/UserBrowserAction.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- UserBrowserAction.java    28 Apr 2002 20:16:55 -0000      1.5
  +++ UserBrowserAction.java    28 Apr 2002 21:00:00 -0000      1.6
  @@ -82,14 +82,23 @@
   import org.apache.jetspeed.modules.actions.portlets.VelocityPortletAction;
   import org.apache.jetspeed.portal.portlets.VelocityPortlet;
   
  +import java.util.Arrays;
  +import java.util.List;
  +
   /**
    * This action sets up the template context for browsing of users in the Turbine 
database.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>David Sean Taylor</a>
  - * @version $Id: UserBrowserAction.java,v 1.5 2002/04/28 20:16:55 kimptoc Exp $
  + * @version $Id: UserBrowserAction.java,v 1.6 2002/04/28 21:00:00 kimptoc Exp $
    */
   public class UserBrowserAction extends VelocityPortletAction
   {
  +    /** name of the parameter to this portlet that tells us how many rows to show 
per page */
  +    public static final String NUMBER_PER_PAGE = "number-per-page";
  +
  +    /** name of the parameter that holds the page number to display */
  +    public static final String DISPLAY_PAGE = "ubpage";
  +
       /**
        * Build the maximized state content for this portlet. (Same as normal state).
        *
  @@ -138,7 +147,51 @@
   
               Criteria criteria = new Criteria();
               User[] users = JetspeedSecurity.getUsers(criteria);
  -            context.put(SecurityConstants.CONTEXT_USERS, users);
  +
  +            List userList = Arrays.asList(users);
  +
  +            int currentPage = rundata.getParameters().getInt(DISPLAY_PAGE, 1);
  +
  +            int numberPerPage;
  +
  +            try
  +            {
  +                numberPerPage = 
Integer.parseInt(portlet.getPortletConfig().getInitParameter(NUMBER_PER_PAGE,"50"));
  +            }
  +            catch (NumberFormatException e)
  +            {
  +                numberPerPage = 50;
  +            }
  +
  +            if (userList.size() > numberPerPage)
  +            {
  +                int numberOfPages = (int) ((userList.size() - 1 + numberPerPage) / 
numberPerPage);
  +                int from = (currentPage - 1) * numberPerPage;
  +                int to = Math.min(currentPage * numberPerPage,userList.size());
  +                context.put(SecurityConstants.CONTEXT_USERS, userList.subList(from, 
to));
  +
  +                //now build a set of links to access each page (assumed we will 
show all links)
  +                StringBuffer pageLinks = new StringBuffer("page: ");
  +                for (int i = 1; i <= numberOfPages; i++)
  +                {
  +                    if (i == currentPage)
  +                    {
  +                        pageLinks.append("( " + i + " ) &nbsp;");
  +                    }
  +                    else
  +                    {
  +                    pageLinks.append("[ <a href=./portal/"+DISPLAY_PAGE+"/" + i + 
">" + i + "</a> ] &nbsp;");
  +                    }
  +                }
  +                context.put("pagelinks", pageLinks);
  +            }
  +            else
  +            {
  +                context.put(SecurityConstants.CONTEXT_USERS, userList);
  +            }
  +            context.put(DISPLAY_PAGE,Integer.toString(currentPage));
  +
  +
           }
           catch (DataBackendException e)
           {
  
  
  
  1.15      +1 -0      jakarta-jetspeed/webapp/WEB-INF/conf/admin.xreg
  
  Index: admin.xreg
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/admin.xreg,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- admin.xreg        19 Apr 2002 04:36:12 -0000      1.14
  +++ admin.xreg        28 Apr 2002 21:00:00 -0000      1.15
  @@ -183,6 +183,7 @@
   
     <portlet-entry type="ref" parent="CustomizerVelocity" name="UserBrowser">
       <security role="admin"/>
  +    <parameter name="number-per-page" value="25"/>
       <parameter name="template" value="user-browser"/>
       <parameter name="action" value="portlets.security.UserBrowserAction"/>
       <meta-info>
  
  
  
  1.4       +5 -1      
jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/user-browser.vm
  
  Index: user-browser.vm
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/user-browser.vm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- user-browser.vm   28 Apr 2002 20:16:55 -0000      1.3
  +++ user-browser.vm   28 Apr 2002 21:00:00 -0000      1.4
  @@ -1,12 +1,14 @@
   #**
   
   @author <a href="mailto:[EMAIL PROTECTED]";>David Sean Taylor</a>
  -@version $Id: user-browser.vm,v 1.3 2002/04/28 20:16:55 kimptoc Exp $
  +@version $Id: user-browser.vm,v 1.4 2002/04/28 21:00:00 kimptoc Exp $
   
   *#
   
   #set ( $headings = ["Username","First Name", "Last Name", "Email", "Actions"] )
   
  +#if ($pagelinks) <p align=right>$pagelinks</p> #end
  +
   <table>
   
     <tr>
  @@ -43,5 +45,7 @@
       <td>
     </tr>
   </table>
  +
  +#if ($pagelinks) <p align=right>$pagelinks</p> #end
   
   
  
  
  
  1.14      +2 -0      jakarta-jetspeed/webapp/css/default.css
  
  Index: default.css
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/css/default.css,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- default.css       28 Apr 2002 20:16:55 -0000      1.13
  +++ default.css       28 Apr 2002 21:00:00 -0000      1.14
  @@ -284,10 +284,12 @@
   
   .UserBrowserUserDisabled
   {
  +    background-color: red;
       text-decoration: line-through;
   }
   
   .UserBrowserUserConfirmed
   {
  +    background-color: yellow;
       font-style: italic;
   }
  
  
  
  1.38      +2 -2      jakarta-jetspeed/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/xdocs/changes.xml,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- changes.xml       28 Apr 2002 20:16:55 -0000      1.37
  +++ changes.xml       28 Apr 2002 21:00:00 -0000      1.38
  @@ -1,6 +1,6 @@
   <?xml version="1.0" encoding="iso-8859-1"?>
   <!--
  -$Id: changes.xml,v 1.37 2002/04/28 20:16:55 kimptoc Exp $
  +$Id: changes.xml,v 1.38 2002/04/28 21:00:00 kimptoc Exp $
   -->
   <document>
     <properties>
  @@ -238,7 +238,7 @@
     Add - 2002/04/09 - added xml media type (DST)
   </li>
   <li>
  -  Add - 2002/04/28 - highlight disabled/unconfirmed users on the user browser page 
(CK)
  +  Add - 2002/04/28 - highlight disabled/unconfirmed users on the user browser page 
and add paging through users (CK)
   </li>
   </ul>
   </section>
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to