KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > databinding > datagrid > runtime > rendering > cell > SpanCellDecorator


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.runtime.rendering.cell;
19
20 import javax.servlet.jsp.JspContext JavaDoc;
21 import javax.servlet.http.HttpServletRequest JavaDoc;
22
23 import org.apache.beehive.netui.databinding.datagrid.api.exceptions.CellDecoratorException;
24 import org.apache.beehive.netui.databinding.datagrid.api.rendering.CellDecorator;
25 import org.apache.beehive.netui.databinding.datagrid.api.rendering.CellModel;
26 import org.apache.beehive.netui.databinding.datagrid.runtime.model.cell.SpanCellModel;
27 import org.apache.beehive.netui.databinding.datagrid.runtime.util.JspUtil;
28 import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender;
29 import org.apache.beehive.netui.tags.rendering.TagRenderingBase;
30
31 /**
32  *
33  */

34 public final class SpanCellDecorator
35     extends CellDecorator {
36
37     public void decorate(JspContext JavaDoc jspContext, AbstractRenderAppender appender, CellModel cellModel)
38             throws CellDecoratorException {
39
40         assert cellModel instanceof SpanCellModel;
41         SpanCellModel spanCellModel = (SpanCellModel)cellModel;
42
43         HttpServletRequest JavaDoc request = JspUtil.getRequest(jspContext);
44         TagRenderingBase span = TagRenderingBase.Factory.getRendering(TagRenderingBase.SPAN_TAG, request);
45
46         String JavaDoc formatted = cellModel.formatText(spanCellModel.getValue());
47
48         span.doStartTag(appender, spanCellModel.getSpanState());
49         appender.append(formatted);
50         span.doEndTag(appender);
51
52         String JavaDoc javascript = spanCellModel.getJavascript();
53         if(javascript != null)
54             appender.append(javascript);
55     }
56 }
57
Popular Tags