KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > table > actions > AbstractPagerAction


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.table.actions;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23 import javax.servlet.http.HttpServletResponse JavaDoc;
24
25 import org.apache.struts.action.ActionForm;
26 import org.apache.struts.action.ActionForward;
27 import org.apache.struts.action.ActionMapping;
28
29 import com.sslexplorer.core.actions.AuthenticatedDispatchAction;
30 import com.sslexplorer.policyframework.Permission;
31 import com.sslexplorer.policyframework.ResourceType;
32 import com.sslexplorer.table.forms.AbstractPagerForm;
33
34 /**
35  * Abstraact class to allow filtering and paging of resources.
36  *
37  * @author James D Robinson <a HREF="mailto:james@3sp.com">&lt;james@3sp.com&gt;</a>
38  *
39  */

40 public abstract class AbstractPagerAction extends AuthenticatedDispatchAction {
41
42     
43     /**
44      * Construtor
45      */

46     public AbstractPagerAction() {
47         super();
48     }
49
50     /**
51      * Construtor
52      *
53      * @param resourceType
54      * @param permissions
55      */

56     public AbstractPagerAction(ResourceType resourceType, Permission[] permissions) {
57         super(resourceType, permissions);
58     }
59
60     /**
61      * Construtor
62      *
63      * @param resourceType
64      * @param permissions
65      * @param requiresResources
66      */

67     public AbstractPagerAction(ResourceType resourceType, Permission[] permissions, ResourceType requiresResources) {
68         super(resourceType, permissions, requiresResources);
69     }
70
71     /**
72      * @param mapping
73      * @param form
74      * @param request
75      * @param response
76      * @return ActionForward
77      * @throws Exception
78      */

79     public ActionForward filter(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request,
80                     HttpServletResponse JavaDoc response) throws Exception JavaDoc {
81         
82         if(mapping.getScope().equalsIgnoreCase("request")) {
83             // Request scoped actions should just re-filter as if they were loading initially
84
// The start row should be reset to 0 incase the filtered item(s) is on a page that is not currently displayed
85
((AbstractPagerForm)form).setStartRow(0);
86             return unspecified(mapping, form, request, response);
87         }
88         else {
89             // Where as session scopes just need to rebuild the pager
90
// The start row should be reset to 0 incase the filtered item(s) is on a page that is not currently displayed
91
((AbstractPagerForm)form).getPager().firstPage();
92             
93             ((AbstractPagerForm)form).getPager().rebuild(((AbstractPagerForm)form).getFilterText());
94             return mapping.findForward("display");
95         }
96     }
97
98 }
99
Popular Tags