/**
   * Creates rows for the inner tables for each field inside this columsn definition
   *
   * @return a List of created AccountingLineTableRows
   */
  protected List<AccountingLineTableRow> createRowsForFields() {
    List<AccountingLineTableRow> rows = new ArrayList<AccountingLineTableRow>();

    int countForThisRow = 0;
    AccountingLineTableRow row = new AccountingLineTableRow();
    for (AccountingLineViewField field : fields) {
      row.addCell(createHeaderCellForField(field));
      row.addCell(createCellForField(field));
      countForThisRow += 1;

      if (countForThisRow == definition.getColumnCount()) {
        rows.add(row);
        countForThisRow = 0;
        row = new AccountingLineTableRow();
      }
    }
    if (countForThisRow > 0) { // oops! we stopped mid-row and now need to fill it out
      while (countForThisRow < definition.getColumnCount()) {
        row.addCell(createPaddingCell());
        countForThisRow += 1;
      }
      rows.add(row);
    }

    return rows;
  }
 /**
  * Joins the given row and header
  *
  * @see
  *     org.kuali.kfs.sys.document.web.TableJoining#joinRow(org.kuali.kfs.sys.document.web.AccountingLineTableRow,
  *     org.kuali.kfs.sys.document.web.AccountingLineTableRow)
  */
 public void joinRow(AccountingLineTableRow headerLabelRow, AccountingLineTableRow row) {
   if (row != null) {
     headerLabelRow.addCell(getLabelCell());
     row.addCell(getPlaceHoldingCell());
   } else {
     headerLabelRow.addCell(getPlaceHoldingCell());
   }
 }
  /**
   * Joins the header row with a line filling cell, which includes within it an inner table that
   * shows all the child fields
   *
   * @see
   *     org.kuali.kfs.sys.document.web.TableJoining#joinRow(org.kuali.kfs.sys.document.web.AccountingLineTableRow,
   *     org.kuali.kfs.sys.document.web.AccountingLineTableRow)
   */
  public void joinRow(AccountingLineTableRow headerLabelRow, AccountingLineTableRow row) {
    AccountingLineTableCell cell = new AccountingLineTableCell();

    AccountingLineTable columnsTable = new AccountingLineTable();

    List<AccountingLineTableRow> rows = createRowsForFields();

    columnsTable.setRows(rows);
    cell.addRenderableElement(columnsTable);
    headerLabelRow.addCell(cell);
  }