KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tags > databinding > datagrid > AbstractHtmlTableCell


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.tags.databinding.datagrid;
19
20 import java.io.IOException JavaDoc;
21 import java.io.StringWriter JavaDoc;
22 import java.util.ArrayList JavaDoc;
23 import javax.servlet.jsp.tagext.JspFragment JavaDoc;
24 import javax.servlet.jsp.JspException JavaDoc;
25 import javax.servlet.http.HttpServletRequest JavaDoc;
26
27 import org.apache.beehive.netui.databinding.datagrid.api.rendering.DataGridTagModel;
28 import org.apache.beehive.netui.databinding.datagrid.runtime.rendering.table.TableRenderer;
29 import org.apache.beehive.netui.databinding.datagrid.runtime.util.JspUtil;
30 import org.apache.beehive.netui.databinding.datagrid.api.sort.SortModel;
31 import org.apache.beehive.netui.databinding.datagrid.api.filter.FilterModel;
32 import org.apache.beehive.netui.tags.IAttributeConsumer;
33 import org.apache.beehive.netui.tags.IBehaviorConsumer;
34 import org.apache.beehive.netui.tags.html.HtmlConstants;
35 import org.apache.beehive.netui.tags.rendering.AbstractHtmlState;
36 import org.apache.beehive.netui.tags.rendering.TdTag;
37 import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender;
38 import org.apache.beehive.netui.util.Bundle;
39
40 /**
41  * <p>
42  * Abstract base class that supports rendering an HTML &lt;td&gt;. This tag should be used as the base class
43  * for all tags which render content during the data grid's {@link DataGridTagModel#RENDER_STATE_GRID} render
44  * state. Subclasses must implement the {@link #renderDataCellContents(org.apache.beehive.netui.tags.rendering.AbstractRenderAppender, String)}
45  * which will be invoked after the opening table cell tag and before the closing table cell tag.
46  * </p>
47  * <p>
48  * State attributes set via the <code>setCell*</code> methods are added to the attribute set used
49  * when rendering the &lt;td&gt; tag.
50  * </p>
51  */

52 public abstract class AbstractHtmlTableCell
53     extends AbstractCell
54     implements IAttributeConsumer, IBehaviorConsumer {
55
56     private String JavaDoc _sortExpression = null;
57     private String JavaDoc _filterExpression = null;
58
59     private TdTag.State _cellState = new TdTag.State();
60
61     /**
62      * <p>
63      * Set the sort expression with which this cell should be associated. Cells use this value
64      * to lookup any {@link org.apache.beehive.netui.databinding.datagrid.api.sort.Sort} state
65      * that may apply to this cell. Often, this value matches a {@link HeaderCell#setSortExpression(String)}
66      * set on a header cell. It is used by data cells to render styles representing sorted data.
67      * </p>
68      * @param sortExpression the sort expression
69      * @jsptagref.attributedescription
70      * @jsptagref.attributesyntaxvalue <i>string</i>
71      * @netui:attribute required="false" rtexprvalue="true"
72      */

73     public void setSortExpression(String JavaDoc sortExpression) {
74         _sortExpression = sortExpression;
75     }
76
77     /**
78      * <p>
79      * Set the filter expression with which this cell should be associated. Cells use this value
80      * to lookup any {@link org.apache.beehive.netui.databinding.datagrid.api.filter.Filter} state
81      * that may apply to this cell. Often, this value matches a {@link HeaderCell#setFilterExpression(String)}
82      * set on a header cell. It is used by data cells to render styles representing filtered data.
83      * </p>
84      * @param filterExpression the filter expression
85      * @jsptagref.attributedescription
86      * <p>
87      * Set the filter expression with which this cell should be associated. Cells use this value
88      * to lookup any {@link org.apache.beehive.netui.databinding.datagrid.api.filter.Filter} state
89      * that may apply to this cell. Often, this value matches a {@link HeaderCell#setFilterExpression(String)}
90      * set on a header cell. It is used by data cells to render styles representing filtered data.
91      * </p>
92      * @jsptagref.attributesyntaxvalue <i>string</i>
93      * @netui:attribute required="false" rtexprvalue="true"
94      */

95     public void setFilterExpression(String JavaDoc filterExpression) {
96         _filterExpression = filterExpression;
97     }
98
99     /* --------------------------------------------------------------
100      *
101      * <td> attributes
102      *
103      * --------------------------------------------------------------
104      */

105
106     /**
107
108      * Sets the onClick JavaScript event for the HTML table cell.
109      *
110      * @param onClick the onClick event.
111      * @jsptagref.attributedescription The onClick JavaScript event for the HTML table cell.
112      * @jsptagref.attributesyntaxvalue <i>string_cellOnClick</i>
113      * @netui:attribute required="false" rtexprvalue="true" description="The onClick JavaScript event."
114      */

115     public void setCellOnClick(String JavaDoc onClick) {
116         _cellState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONCLICK, onClick);
117     }
118
119     /**
120      * Sets the onDblClick javascript event for the HTML table cell.
121      *
122      * @param onDblClick the onDblClick event.
123      * @jsptagref.attributedescription The onDblClick JavaScript event for the HTML table cell.
124      * @jsptagref.attributesyntaxvalue <i>string_cellOnDblClick</i>
125      * @netui:attribute required="false" rtexprvalue="true" description="The onDblClick JavaScript event."
126      */

127     public void setCellOnDblClick(String JavaDoc onDblClick) {
128         _cellState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONDBLCLICK, onDblClick);
129     }
130
131     /**
132      * Sets the onKeyDown javascript event for the HTML table cell.
133      *
134      * @param onKeyDown the onKeyDown event.
135      * @jsptagref.attributedescription The onKeyDown JavaScript event for the HTML table cell.
136      * @jsptagref.attributesyntaxvalue <i>string_cellOnKeyDown</i>
137      * @netui:attribute required="false" rtexprvalue="true" description="The onKeyDown JavaScript event."
138      */

139     public void setCellOnKeyDown(String JavaDoc onKeyDown) {
140         _cellState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONKEYDOWN, onKeyDown);
141     }
142
143     /**
144      * Sets the onKeyUp javascript event for the HTML table cell.
145      *
146      * @param onKeyUp the onKeyUp event.
147      * @jsptagref.attributedescription The onKeyUp JavaScript event for the HTML table cell.
148      * @jsptagref.attributesyntaxvalue <i>string_cellOnKeyUp</i>
149      * @netui:attribute required="false" rtexprvalue="true" description="The onKeyUp JavaScript event."
150      */

151     public void setCellOnKeyUp(String JavaDoc onKeyUp) {
152         _cellState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONKEYUP, onKeyUp);
153     }
154
155     /**
156      * Sets the onKeyPress javascript event for the HTML table cell.
157      *
158      * @param onKeyPress the onKeyPress event.
159      * @jsptagref.attributedescription The onKeyPress JavaScript event for the HTML table cell.
160      * @jsptagref.attributesyntaxvalue <i>string_cellOnKeyPress</i>
161      * @netui:attribute required="false" rtexprvalue="true" description="The onKeyPress JavaScript event."
162      */

163     public void setCellOnKeyPress(String JavaDoc onKeyPress) {
164         _cellState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONKEYPRESS, onKeyPress);
165     }
166
167     /**
168      * Sets the onMouseDown javascript event for the HTML table cell.
169      *
170      * @param onMouseDown the onMouseDown event.
171      * @jsptagref.attributedescription The onMouseDown JavaScript event for the HTML table cell.
172      * @jsptagref.attributesyntaxvalue <i>string_cellOnMouseDown</i>
173      * @netui:attribute required="false" rtexprvalue="true" description="The onMouseDown JavaScript event."
174      */

175     public void setCellOnMouseDown(String JavaDoc onMouseDown) {
176         _cellState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEDOWN, onMouseDown);
177     }
178
179     /**
180      * Sets the onMouseUp javascript event for the HTML table cell.
181      *
182      * @param onMouseUp the onMouseUp event.
183      * @jsptagref.attributedescription The onMouseUp JavaScript event for the HTML table cell.
184      * @jsptagref.attributesyntaxvalue <i>string_cellOnMouseUp</i>
185      * @netui:attribute required="false" rtexprvalue="true" description="The onMouseUp JavaScript event."
186      */

187     public void setCellOnMouseUp(String JavaDoc onMouseUp) {
188         _cellState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEUP, onMouseUp);
189     }
190
191     /**
192      * Sets the onMouseMove javascript event for the HTML table cell.
193      *
194      * @param onMouseMove the onMouseMove event.
195      * @jsptagref.attributedescription The onMouseMove JavaScript event for the HTML table cell.
196      * @jsptagref.attributesyntaxvalue <i>string_cellOnMouseMove</i>
197      * @netui:attribute required="false" rtexprvalue="true" description="The onMouseMove JavaScript event."
198      */

199     public void setCellOnMouseMove(String JavaDoc onMouseMove) {
200         _cellState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEMOVE, onMouseMove);
201     }
202
203     /**
204      * Sets the onMouseOut javascript event for the HTML table cell.
205      *
206      * @param onMouseOut the onMouseOut event.
207      * @jsptagref.attributedescription The onMouseOut JavaScript event for the HTML table cell.
208      * @jsptagref.attributesyntaxvalue <i>string_cellOnMouseOut</i>
209      * @netui:attribute required="false" rtexprvalue="true" description="The onMouseOut JavaScript event."
210      */

211     public void setCellOnMouseOut(String JavaDoc onMouseOut) {
212         _cellState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEOUT, onMouseOut);
213     }
214
215     /**
216      * Sets the onMouseOver javascript event for the HTML table cell.
217      *
218      * @param onMouseOver the onMouseOver event.
219      * @jsptagref.attributedescription The onMouseOver JavaScript event for the HTML table cell.
220      * @jsptagref.attributesyntaxvalue <i>string_cellOnMouseOver</i>
221      * @netui:attribute required="false" rtexprvalue="true" description="The onMouseOver JavaScript event."
222      */

223     public void setCellOnMouseOver(String JavaDoc onMouseOver) {
224         _cellState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEOVER, onMouseOver);
225     }
226
227     /**
228      * Sets the style attribute for the HTML table cell.
229      *
230      * @param style the html style.
231      * @jsptagref.attributedescription The style attribute for the HTML table cell.
232      * @jsptagref.attributesyntaxvalue <i>string_cellStyle</i>
233      * @netui:attribute required="false" rtexprvalue="true" description="The style attribute."
234      */

235     public void setCellStyle(String JavaDoc style) {
236         if("".equals(style)) return;
237
238         _cellState.style = style;
239     }
240
241     /**
242      * Sets the style class attribute for the HTML table cell.
243      *
244      * @param styleClass the html style class.
245      * @jsptagref.attributedescription The style class attribute for the HTML table cell.
246      * @jsptagref.attributesyntaxvalue <i>string_cellStyleClass</i>
247      * @netui:attribute required="false" rtexprvalue="true" description="The style class."
248      */

249     public void setCellStyleClass(String JavaDoc styleClass) {
250         if("".equals(styleClass)) return;
251
252         _cellState.styleClass = styleClass;
253     }
254
255     /**
256      * Sets the value of the title attribute for the HTML table cell.
257      *
258      * @param title the title
259      * @jsptagref.attributedescription The title for the HTML table cell.
260      * @jsptagref.attributesyntaxvalue <i>string_cellTitle</i>
261      * @netui:attribute required="false" rtexprvalue="true" description="The title."
262      */

263     public void setCellTitle(String JavaDoc title) {
264         _cellState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.TITLE, title);
265     }
266
267     /**
268      * Sets the rowspan attribute for the HTML table cell.
269      *
270      * @param rowSpan the rowspan
271      * @jsptagref.attributedescription The row span attribute for the HTML table cell.
272      * @jsptagref.attributesyntaxvalue <i>string_cellRowspan</i>
273      * @netui:attribute required="false" rtexprvalue="true" description="The rowspan."
274      */

275     public void setCellRowspan(int rowSpan) {
276         _cellState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.ROWSPAN, "" + rowSpan);
277     }
278
279     /**
280      * Sets the colspan attribute of the HTML table cell.
281      *
282      * @param colSpan the colspan
283      * @jsptagref.attributedescription The colspan attribute of the HTML table cell.
284      * @jsptagref.attributesyntaxvalue <i>string_cellColspan</i>
285      * @netui:attribute required="false" rtexprvalue="true" description="The colspan."
286      */

287     public void setCellColspan(int colSpan) {
288         _cellState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.COLSPAN, "" + colSpan);
289     }
290
291     /**
292      * Sets the horizontal alignment of the HTML table cell.
293      *
294      * @param align the alignment
295      * @jsptagref.attributedescription The horizontal alignment of the HTML table cell.
296      * @jsptagref.attributesyntaxvalue <i>string_cellAlign</i>
297      * @netui:attribute required="false" rtexprvalue="true" description="The cell's horizontal alignment"
298      */

299     public void setCellAlign(String JavaDoc align) {
300         /* todo: should this enforce left|center|right|justify|char as in the spec */
301         _cellState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.ALIGN, align);
302     }
303
304     /**
305      * Sets the value of the horizontal alignment character attribute for the HTML table cell.
306      *
307      * @param alignChar the horizontal alignment character
308      * @jsptagref.attributedescription The horizontal alignment character for the HTML table cell
309      * @jsptagref.attributesyntaxvalue <i>string_cellAlignChar</i>
310      * @netui:attribute required="false" rtexprvalue="true" description="The cell's horizontal alignment character"
311      */

312     public void setCellChar(String JavaDoc alignChar) {
313         _cellState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.CHAR, alignChar);
314     }
315
316     /**
317      * Sets the value of the horizontal alignment character offset attribute for the HTML table cell.
318      *
319      * @param alignCharOff the alingnment character offset
320      * @jsptagref.attributedescription The horizontal alignment character offset for the HTML table cell.
321      * @jsptagref.attributesyntaxvalue <i>string_cellAignCharOff</i>
322      * @netui:attribute required="false" rtexprvalue="true" description="The cell's horizontal alignment character offset"
323      */

324     public void setCellCharoff(String JavaDoc alignCharOff) {
325         _cellState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.CHAROFF, alignCharOff);
326     }
327
328     /**
329      * Sets the value of the vertical alignment attribute for the HTML table cell.
330      *
331      * @param align the vertical alignment
332      * @jsptagref.attributedescription The vertical alignment for the HTML table cell.
333      * @jsptagref.attributesyntaxvalue <i>string_cellAlign</i>
334      * @netui:attribute required="false" rtexprvalue="true" description="The cell's vertical alignment"
335      */

336     public void setCellValign(String JavaDoc align) {
337         /* todo: should this enforce top|middle|bottom|baseline as in the spec */
338         _cellState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.VALIGN, align);
339     }
340
341     /**
342      * Sets the value of the language attribute for the HTML table cell.
343      *
344      * @param lang the language
345      * @jsptagref.attributedescription The language for the HTML table cell.
346      * @jsptagref.attributesyntaxvalue <i>string_cellLang</i>
347      * @netui:attribute required="false" rtexprvalue="true" description="The cell's language"
348      */

349     public void setCellLang(String JavaDoc lang) {
350         _cellState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.LANG, lang);
351     }
352
353     /**
354      * Sets the value of the text direction attribute for the HTML table cell.
355      *
356      * @param dir the text direction
357      * @jsptagref.attributedescription The text direction attribute for the HTML table cell.
358      * @jsptagref.attributesyntaxvalue <i>string_cellDir</i>
359      * @netui:attribute required="false" rtexprvalue="true" description="The cell's text direction"
360      */

361     public void setCellDir(String JavaDoc dir) {
362         _cellState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.DIR, dir);
363     }
364
365     /**
366      * Sets the value of the abbreviated form of the HTML table cell's content.
367      *
368      * @param abbr the abbreviation
369      * @jsptagref.attributedescription The abbreviated form of the HTML table cell's content.
370      * @jsptagref.attributesyntaxvalue <i>string_cellAbbr</i>
371      * @netui:attribute required="false" rtexprvalue="true" description="The abbreviated form of the cell's content"
372      */

373     public void setCellAbbr(String JavaDoc abbr) {
374         _cellState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.ABBR, abbr);
375     }
376
377     /**
378      * Sets the value of the axis attribute for the HTML table cell.
379      *
380      * @param axis the axis
381      * @jsptagref.attributedescription The axis attribute for the HTML table cell.
382      * @jsptagref.attributesyntaxvalue <i>string_cellAxis</i>
383      * @netui:attribute required="false" rtexprvalue="true" description="The axis attribute"
384      */

385     public void setCellAxis(String JavaDoc axis) {
386         _cellState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.AXIS, axis);
387     }
388
389     /**
390      * Sets the value of the headers attribute for the HTML table cell.
391      *
392      * @param headers the headers
393      * @jsptagref.attributedescription The headers attribute for the HTML table cell.
394      * @jsptagref.attributesyntaxvalue <i>string_cellHeaders</i>
395      * @netui:attribute required="false" rtexprvalue="true" description="The headers attribute"
396      */

397     public void setCellHeaders(String JavaDoc headers) {
398         _cellState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.HEADERS, headers);
399     }
400
401     /**
402      * Sets the value of the scope attribute for the HTML table cell.
403      *
404      * @param scope the scope
405      * @jsptagref.attributedescription The scope attribute for the HTML table cell.
406      * @jsptagref.attributesyntaxvalue <i>string_cellScope</i>
407      * @netui:attribute required="false" rtexprvalue="true" description="The scope attribute"
408      */

409     public void setCellScope(String JavaDoc scope) {
410         _cellState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.SCOPE, scope);
411     }
412
413     /**
414      * Set the name of the tagId for the HTML table cell. The user is responsible for ensuring that
415      * this tag id is unique in the rendered page.
416      *
417      * @param tagId the tag id
418      * @jsptagref.attributedescription The tagId for the HTML table cell. The user is responsible for
419      * ensuring that this tag id is unique in the rendered page.
420      * @jsptagref.attributesyntaxvalue <i>string_cellTagId</i>
421      * @netui:attribute required="false" rtexprvalue="true"
422      * description="String value. Sets the id (or name) attribute of the rendered HTML tag. "
423      */

424     public void setCellTagId(String JavaDoc tagId)
425         throws JspException JavaDoc {
426         applyTagId(_cellState, tagId);
427     }
428
429     /**
430      * <p>
431      * Base support for setting attributes on a tag via the {@link IAttributeConsumer} interface. The
432      * AbstractHtmlTableCell does not support any attributes by default. Attributes set via this interface
433      * are used to extend the HTML attributes exposed through the JSP tags themselves. This allows
434      * tag users to add arbitrary attributes to the HTML tags rendered by the data grid.
435      * </p>
436      *
437      * @param name The name of the attribute.
438      * @param value The value of the attribute.
439      * @param facet The name of a facet to which the attribute will be applied. This is optional.
440      * @throws JspException
441      */

442     public void setAttribute(String JavaDoc name, String JavaDoc value, String JavaDoc facet)
443             throws JspException JavaDoc {
444         String JavaDoc s = Bundle.getString("Tags_AttributeFacetNotSupported", new Object JavaDoc[]{facet});
445         throw new JspException JavaDoc(s);
446     }
447
448     /**
449      * <p>
450      * Base support for setting behavior values via the {@link IBehaviorConsumer} interface. The
451      * AbstractHtmlTableCell does not support any attributes by default. Attributes set via this
452      * interface are used to configure internal functionality of the tags which is not exposed
453      * via JSP tag attributes.
454      * </p>
455      * @param name the name of the behavior
456      * @param value the value of the behavior
457      * @param facet the name of a facet of the tag to which the behavior will be applied. This is optional.
458      * @throws JspException
459      */

460     public void setBehavior(String JavaDoc name, Object JavaDoc value, String JavaDoc facet)
461             throws JspException JavaDoc {
462         String JavaDoc s = Bundle.getString("Tags_BehaviorFacetNotSupported", new Object JavaDoc[]{facet});
463         throw new JspException JavaDoc(s);
464     }
465
466     /**
467      * <p>
468      * Base HTML table cell rendering functionality which opens and closes the HTML &lt;td&gt; tags with
469      * the correct style and attribute information. Between the table cell tags, the tag
470      * calls the {@link #renderDataCellContents(org.apache.beehive.netui.tags.rendering.AbstractRenderAppender, String)}
471      * method so that subclasses implementing this method can provide content inside of the table cell.
472      * </p>
473      * <p>
474      * The style information rendered here includes the following in order:
475      * <ol>
476      * <li>the {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.StyleModel#getDataCellFilteredClass()}
477      * if the cell has a filter expression and is filtered
478      * </li>
479      * <li>the {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.StyleModel#getDataCellSortedClass()}
480      * if the cell has a sort expression and is sorted
481      * <li>the {@link #setCellStyleClass(String)} attribute if set;
482      * {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.StyleModel#getDataCellClass()} otherwise</li>
483      * </ol>
484      * </p>
485      * @param appender the {@link AbstractRenderAppender} to which any output should be rendered
486      * @throws IOException
487      * @throws JspException
488      */

489     protected void renderCell(AbstractRenderAppender appender)
490             throws IOException JavaDoc, JspException JavaDoc {
491
492         DataGridTagModel dataGridModel = DataGridUtil.getDataGridTagModel(getJspContext());
493         if(dataGridModel == null)
494             throw new JspException JavaDoc(Bundle.getErrorString("DataGridTags_MissingDataGridModel"));
495
496         TableRenderer tableRenderer = dataGridModel.getTableRenderer();
497         assert tableRenderer != null;
498
499         /* todo: refactor. extensibility in supporting style decorators */
500         ArrayList JavaDoc/*<String>*/ styleClasses = new ArrayList JavaDoc/*<String>*/();
501         FilterModel filterModel = dataGridModel.getState().getFilterModel();
502         if(_filterExpression != null && filterModel.isFiltered(_filterExpression))
503             styleClasses.add(dataGridModel.getStyleModel().getDataCellFilteredClass());
504
505         SortModel sortModel = dataGridModel.getState().getSortModel();
506         if(_sortExpression != null && sortModel.isSorted(_sortExpression))
507             styleClasses.add(dataGridModel.getStyleModel().getDataCellSortedClass());
508
509         if(_cellState.styleClass == null)
510             styleClasses.add(dataGridModel.getStyleModel().getDataCellClass());
511         else
512             styleClasses.add(_cellState.styleClass);
513
514         _cellState.styleClass = dataGridModel.getStyleModel().buildStyleClassValue(styleClasses);
515
516         /*
517            note, this runs in order to allow any nested tags to do their work.
518            this provides support for formatters, parameters, etc
519          */

520         JspFragment JavaDoc fragment = getJspBody();
521         StringWriter JavaDoc sw = new StringWriter JavaDoc();
522         if(fragment != null)
523             fragment.invoke(sw);
524
525         tableRenderer.openTableCell(_cellState, appender);
526         renderDataCellContents(appender, sw.toString());
527         tableRenderer.closeTableCell(appender);
528
529         /* todo: need to add the JavaScript rendering for any tagIds that were set on <td>s */
530         if (_cellState.id != null) {
531             HttpServletRequest JavaDoc request = JspUtil.getRequest(getJspContext());
532             String JavaDoc script = renderNameAndId(request, _cellState, null);
533             if(script != null)
534                 appender.append(script);
535         }
536
537     }
538
539     /**
540      * <p>
541      * Abstract method implemented by subclasses in order to render a cell's content.
542      * </p>
543      * @param appender the {@link AbstractRenderAppender} to which any output should be rendered
544      * @param output the output produced from having evaluated this tag's {@link JspFragment}
545      * @throws IOException
546      * @throws JspException
547      */

548     protected abstract void renderDataCellContents(AbstractRenderAppender appender, String JavaDoc output)
549             throws IOException JavaDoc, JspException JavaDoc;
550 }
551
Popular Tags