KickJava   Java API By Example, From Geeks To Geeks.

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


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.hivemind.ApplicationRuntimeException;
18 import org.apache.tapestry.BaseComponent;
19 import org.apache.tapestry.IRequestCycle;
20 import org.apache.tapestry.contrib.table.model.ITableModelSource;
21
22 /**
23  * The base implementation for a component that is wrapped by
24  * the TableView component. Provides a utility method for getting
25  * a pointer to TableView.
26  *
27  * @author mindbridge
28  */

29 public abstract class AbstractTableViewComponent extends BaseComponent
30 {
31     public ITableModelSource getTableModelSource()
32     {
33         IRequestCycle objCycle = getPage().getRequestCycle();
34
35         ITableModelSource objSource =
36             (ITableModelSource) objCycle.getAttribute(
37                 ITableModelSource.TABLE_MODEL_SOURCE_ATTRIBUTE);
38
39         if (objSource == null)
40             throw new ApplicationRuntimeException(
41                 "The component "
42                     + getId()
43                     + " must be contained within an ITableModelSource component, such as TableView",
44                 this,
45                 null,
46                 null);
47
48         return objSource;
49     }
50
51 }
52
Popular Tags