KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > contrib > table > components > Table


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.components;
16
17 import org.apache.tapestry.BaseComponent;
18 import org.apache.tapestry.contrib.table.model.ITableColumn;
19 import org.apache.tapestry.contrib.table.model.ITableModel;
20 import org.apache.tapestry.contrib.table.model.ITableModelSource;
21
22 /**
23  * The facade component in the Table family. Table allows you to present a sortable and pagable
24  * table simply and easily by using only this one component. Please see the Component Reference for
25  * details on how to use this component. [ <a
26  * HREF="../../../../../../../ComponentReference/contrib.Table.html">Component Reference </a>]
27  *
28  * @author mindbridge
29  */

30 public abstract class Table extends BaseComponent implements ITableModelSource
31 {
32     /**
33      * @see org.apache.tapestry.contrib.table.model.ITableModelSource#getTableModel()
34      */

35     public ITableModel getTableModel()
36     {
37         return getTableViewComponent().getTableModel();
38     }
39
40     /**
41      * Indicates that the table model has changed and it may need to saved. This method has to be
42      * invoked if modifications are made to the model.
43      *
44      * @see org.apache.tapestry.contrib.table.model.ITableModelSource#fireObservedStateChange()
45      */

46     public void fireObservedStateChange()
47     {
48         getTableViewComponent().fireObservedStateChange();
49     }
50
51     /**
52      * Resets the state of the component and forces it to load a new TableModel from the tableModel
53      * binding the next time it renders.
54      */

55     public void reset()
56     {
57         getTableViewComponent().reset();
58     }
59
60     /**
61      * Returns the currently rendered table column. You can call this method to obtain the current
62      * column.
63      *
64      * @return ITableColumn the current table column
65      */

66     public ITableColumn getTableColumn()
67     {
68         Object JavaDoc objCurrentRow = getTableRow();
69
70         // if the current row is null, then we are most likely rendering TableColumns
71
if (objCurrentRow == null)
72             return getTableColumnsComponent().getTableColumn();
73
74         return getTableValuesComponent().getTableColumn();
75     }
76
77     /**
78      * Returns the currently rendered table row or null if the rows are not rendered at the moment.
79      * You can call this method to obtain the current row.
80      *
81      * @return Object the current table row
82      */

83     public Object JavaDoc getTableRow()
84     {
85         return getTableRowsComponent().getTableRow();
86     }
87
88     protected TableView getTableViewComponent()
89     {
90         return (TableView) getComponent("tableView");
91     }
92
93     protected TableColumns getTableColumnsComponent()
94     {
95         return (TableColumns) getComponent("tableColumns");
96     }
97
98     protected TableRows getTableRowsComponent()
99     {
100         return (TableRows) getComponent("tableRows");
101     }
102
103     protected TableValues getTableValuesComponent()
104     {
105         return (TableValues) getComponent("tableValues");
106     }
107 }
Popular Tags