KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > webapp > action > core > grid > BaseGridAction


1 /*
2  * Copyright 2004 Blandware (http://www.blandware.com)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package com.blandware.atleap.webapp.action.core.grid;
17
18 import com.blandware.atleap.webapp.action.core.BaseAction;
19 import com.blandware.atleap.webapp.taglib.core.grid.util.Grid;
20 import com.blandware.atleap.webapp.taglib.core.util.TaglibConstants;
21
22 import javax.servlet.http.HttpSession JavaDoc;
23 import java.util.Collections JavaDoc;
24 import java.util.HashMap JavaDoc;
25 import java.util.Map JavaDoc;
26
27 /**
28  * <p>Base action for all grid actions.
29  * Contains some base methods for grid actions.
30  * </p>
31  * <p><a HREF="BaseGridAction.java.htm"><i>View Source</i></a></p>
32  * <p/>
33  *
34  * @author Sergey Zubtcovskii <a HREF="mailto:sergey.zubtcovskii@blandware.com">&lt;sergey.zubtcovskii@blandware.com&gt;</a>
35  * @version $Revision: 1.4 $ $Date: 2005/08/05 17:48:18 $
36  */

37 public class BaseGridAction extends BaseAction {
38
39     /**
40      * Gets grid by specified name from the session
41      *
42      * @param gridName Name of grid to search by
43      * @param session Http session to search in
44      * @return Grid if it was found and else otherwise
45      */

46     protected Grid getGridByName(String JavaDoc gridName, HttpSession JavaDoc session) {
47         Grid grid = null;
48         Map JavaDoc grids = (Map JavaDoc) session.getAttribute(TaglibConstants.GRIDS);
49         if ( grids != null ) {
50             grid = (Grid) grids.get(gridName);
51         }
52         return grid;
53     }
54
55     /**
56      * Saves grid in session
57      *
58      * @param grid Grid to save
59      * @param session Http session to save in
60      */

61     protected void saveGrid(Grid grid, HttpSession JavaDoc session) {
62         Map JavaDoc grids = (Map JavaDoc) session.getAttribute(TaglibConstants.GRIDS);
63         if ( grids == null ) {
64             grids = Collections.synchronizedMap(new HashMap JavaDoc());
65         }
66         grids.put(grid.getName(), grid);
67         session.setAttribute(TaglibConstants.GRIDS, grids);
68     }
69
70 }
Popular Tags