code: public void doTag()
              throws IOException, JspException {
  
          JspContext jspContext = getJspContext();
          DataGridTagModel dgm = DataGridUtil.getDataGridTagModel(jspContext);
          if(dgm == null)
              throw new JspException(Bundle.getErrorString("DataGridTags_MissingDataGridModel"));
  
          if(dgm.getRenderState() == DataGridTagModel.RENDER_STATE_CAPTION) {
              JspFragment fragment = getJspBody();
              if(fragment != null) {
                  String captionScript = null;
                  if(_captionTag.id != null) {
                      HttpServletRequest request = JspUtil.getRequest(getJspContext());
                      captionScript = renderNameAndId(request, _captionTag, null);
                  }
  
                  StringWriter sw = new StringWriter();
                  TableRenderer tableRenderer = dgm.getTableRenderer();
                  StyleModel stylePolicy = dgm.getStyleModel();
                  AbstractRenderAppender appender = new WriteRenderAppender(jspContext);
  
                  if(_captionTag.styleClass == null)
                      _captionTag.styleClass = stylePolicy.getCaptionClass();
  
                  tableRenderer.openCaption(_captionTag, appender);
  
                  fragment.invoke(sw);
                  appender.append(sw.toString());
  
                  tableRenderer.closeCaption(appender);
  
                  if(captionScript != null)
                      appender.append(captionScript);
              }
          }
      }
docs: <p>
  Render the caption tag.  This tag renders during the data grid's {@link DataGridTagModel#RENDER_STATE_CAPTION}
  state and produces an HTML &lt;caption&gt; which contains the result of having evaluated
  the body of this tag.
  </p>
  @throws IOException
  @throws JspException when the {@link DataGridTagModel} can not be found in the {@link JspContext}