KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > databinding > datagrid > api > rendering > CellDecorator


1 /*
2  * Copyright 2004 The Apache Software Foundation.
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  * $Header:$
17  */

18 package org.apache.beehive.netui.databinding.datagrid.api.rendering;
19
20 import javax.servlet.jsp.JspContext JavaDoc;
21
22 import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender;
23 import org.apache.beehive.netui.databinding.datagrid.api.exceptions.CellDecoratorException;
24
25 /**
26  * <p>
27  * Abstract basee class used to render the contents of a data grid cell. CellDecorators are used so that
28  * code used to render the contents of a data grid cell can be chained together in order to compose
29  * different rendering patterns. For example, an HTML anchor and image decorator could be composed together
30  * to create an image anchor renderer. In addition, cell decoration can be used to display UI exposing
31  * custom data grid features such as sort or filter UI on data grid header cells.
32  * </p>
33  * <p>
34  * CellDecorators are intended to be <b>stateless</b>. State required for rendering should be passed to
35  * a CellDecorator using an instance of a {@link CellModel} class.
36  * </p>
37  */

38 public abstract class CellDecorator {
39
40     /**
41      * This decorator can be optionally used by implementations to
42      * render additional UI for the cell.
43      */

44     private CellDecorator _cellDecorator = null;
45
46     /**
47      * Default constructor.
48      */

49     public CellDecorator() {
50     }
51
52     /**
53      * Constructor that takes a nested CellDecorator.
54      *
55      * @param cellDecorator the nested decorator which can optionally be used by implementations
56      * to render additional UI for the cell.
57      */

58     public CellDecorator(CellDecorator cellDecorator) {
59         this();
60         _cellDecorator = cellDecorator;
61     }
62
63     /**
64      * Get the nested decorator.
65      *
66      * @return the cell decorator if one has been provided. <code>null</code> otherwise.
67      */

68     public CellDecorator getNestedDecorator() {
69         return _cellDecorator;
70     }
71
72     /**
73      * Set the nested cell decorator.
74      *
75      * @param cellDecorator the cell decorator.
76      */

77     public void setNestedDecorator(CellDecorator cellDecorator) {
78         _cellDecorator = cellDecorator;
79     }
80
81     /**
82      * This method is implemented by subclasses to provide decoration behavior. The use of a nested CellDecorator
83      * is left to specific implementations; it is possible that some implementations will ignore such
84      * nested instances.
85      *
86      * @param jspContext the {@link JspContext} for the current page
87      * @param appender the {@link AbstractRenderAppender} to which markup should be rendered
88      * @param cellModel the {@link CellModel} JavaBean that contains
89      * @throws CellDecoratorException an exception thrown when an error occurs running the decorator.
90      */

91     public abstract void decorate(JspContext JavaDoc jspContext, AbstractRenderAppender appender, CellModel cellModel)
92             throws CellDecoratorException;
93 }
94
Popular Tags