KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > contrib > table > model > simple > SimpleTableSessionStateManager


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

15 package org.apache.tapestry.contrib.table.model.simple;
16
17 import java.io.Serializable JavaDoc;
18
19 import org.apache.tapestry.contrib.table.model.ITableColumnModel;
20 import org.apache.tapestry.contrib.table.model.ITableDataModel;
21 import org.apache.tapestry.contrib.table.model.ITableModel;
22 import org.apache.tapestry.contrib.table.model.ITableSessionStateManager;
23
24 /**
25  * A {@link org.apache.tapestry.contrib.table.model.ITableSessionStateManager}
26  * implementation that saves only the paging and sorting state of the table model
27  * into the session.
28  *
29  * @author mindbridge
30  */

31 public class SimpleTableSessionStateManager
32     implements ITableSessionStateManager
33 {
34     private ITableDataModel m_objDataModel;
35     private ITableColumnModel m_objColumnModel;
36
37     public SimpleTableSessionStateManager(
38         ITableDataModel objDataModel,
39         ITableColumnModel objColumnModel)
40     {
41         m_objDataModel = objDataModel;
42         m_objColumnModel = objColumnModel;
43     }
44
45     /**
46      * @see org.apache.tapestry.contrib.table.model.ITableSessionStateManager#getSessionState(ITableModel)
47      */

48     public Serializable JavaDoc getSessionState(ITableModel objModel)
49     {
50         SimpleTableModel objSimpleModel = (SimpleTableModel) objModel;
51         return objSimpleModel.getState();
52     }
53
54     /**
55      * @see org.apache.tapestry.contrib.table.model.ITableSessionStateManager#recreateTableModel(Serializable)
56      */

57     public ITableModel recreateTableModel(Serializable JavaDoc objState)
58     {
59         if (objState == null)
60             return null;
61         SimpleTableState objSimpleState = (SimpleTableState) objState;
62         return new SimpleTableModel(
63             m_objDataModel,
64             m_objColumnModel,
65             objSimpleState);
66     }
67
68 }
69
Popular Tags