001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: * $Header:$
018: */
019: package org.apache.beehive.netui.tags.databinding.datagrid;
020:
021: import org.apache.beehive.netui.databinding.datagrid.api.rendering.CellModel;
022: import org.apache.beehive.netui.databinding.datagrid.runtime.model.cell.TemplateCellModel;
023: import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender;
024:
025: /**
026: * <p>
027: * Data grid cell that renders the content contained inside of its body inside of an HTML <td>
028: * tag. The body of the template cell can contain any JSP markup that is legal to nest inside of
029: * a {@link javax.servlet.jsp.tagext.SimpleTag}.
030: * </p>
031: * <p>
032: * The templateCell can be used to render HTML UI that is not supported with other data grid cell types. For example,
033: * to build UI that will POST data to a form, the NetUI {@link org.apache.beehive.netui.tags.html.TextBox} tag can
034: * be used as:
035: * <pre>
036: * <netui-data:templateCell>
037: * <netui:textBox dataSource="container.item.name"/>
038: * </netui-data:templateCell>
039: * </pre>
040: * </p>
041: * <p>
042: * The set of JSP implicit objects available to the body include:
043: * <ul>
044: * <li><code>dataGridModel</code> -- the {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.DataGridTagModel}
045: * for the cell's containing data grid.</li>
046: * <li><code>container</code> -- the {@link org.apache.beehive.netui.script.common.IDataAccessProvider} instance
047: * that exposes the current data item and the current item's index</li>
048: * </ul>
049: * </p>
050: * <p>
051: * The HTML events, core attributes, and internationalization JSP tag attributes are applied to the
052: * <td>.
053: * </p>
054: *
055: * @jsptagref.tagdescription
056: * <p>
057: * Data grid cell that renders the content contained inside of its body inside of an HTML <td>
058: * tag. The body of the template cell can contain any JSP markup that is legal to nest inside of
059: * a {@link javax.servlet.jsp.tagext.SimpleTag}.
060: * </p>
061: * <p>
062: * The templateCell can be used to render HTML UI that is not supported with other data grid cell types. For example,
063: * to build UI that will POST data to a form, the NetUI {@link org.apache.beehive.netui.tags.html.TextBox} tag can
064: * be used as:
065: * <pre>
066: * <netui-data:templateCell>
067: * <netui:textBox dataSource="container.item.name"/>
068: * </netui-data:templateCell>
069: * </pre>
070: * </p>
071: * <p>
072: * The set of JSP implicit objects available to the body include:
073: * <ul>
074: * <li><code>dataGridModel</code> -- the {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.DataGridTagModel}
075: * for the cell's containing data grid.</li>
076: * <li><code>container</code> -- the {@link org.apache.beehive.netui.script.common.IDataAccessProvider} instance
077: * that exposes the current data item and the current item's index</li>
078: * </ul>
079: * </p>
080: * <p>
081: * The HTML events, core attributes, and internationalization JSP tag attributes are applied to the
082: * <td>.
083: * </p>
084: *
085: * @netui:tag name="templateCell" body-content="scriptless"
086: * description="Data grid cell that renders the content resulting from evaluating its body"
087: */
088: public class TemplateCell extends AbstractHtmlTableCell {
089:
090: /**
091: * The name of this tag; this value is used for error reporting.
092: * @return the String name of this tag
093: */
094: public String getTagName() {
095: return "TemplateCell";
096: }
097:
098: /**
099: * Render the contents of this cell. For this tag, the result of executing the
100: * {@link javax.servlet.jsp.tagext.JspFragment} is added to the output stream.
101: * @param appender the {@link AbstractRenderAppender} used for output
102: * @param jspFragmentOutput the result of evaluating the body of the tag.
103: */
104: protected void renderDataCellContents(
105: AbstractRenderAppender appender, String jspFragmentOutput) {
106: appender.append(jspFragmentOutput);
107: }
108:
109: /**
110: * Implementation of {@link AbstractHtmlTableCell#internalGetCellModel()} that exposes the
111: * {@link org.apache.beehive.netui.databinding.datagrid.runtime.model.cell.TemplateCellModel}
112: * which is storing state for this tag.
113: * @return this tag's template cell model
114: */
115: protected CellModel internalGetCellModel() {
116: return new TemplateCellModel();
117: }
118: }
|