001/* 002 * Copyright 2008 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.ole.sys.document.web; 017 018import java.util.ArrayList; 019import java.util.List; 020 021import javax.servlet.jsp.JspException; 022import javax.servlet.jsp.PageContext; 023import javax.servlet.jsp.tagext.Tag; 024 025import org.kuali.ole.sys.document.web.renderers.TableRenderer; 026import org.kuali.rice.kns.web.ui.Field; 027 028/** 029 * An inner table inside a table cell. 030 */ 031public class AccountingLineTable implements RenderableElement { 032 private List<AccountingLineTableRow> rows; 033 private AccountingLineRenderingContext renderingContext; 034 035 /** 036 * Gets the rows attribute. 037 * @return Returns the rows. 038 */ 039 public List<AccountingLineTableRow> getRows() { 040 return rows; 041 } 042 043 /** 044 * Sets the rows attribute value. 045 * @param rows The rows to set. 046 */ 047 public void setRows(List<AccountingLineTableRow> rows) { 048 this.rows = rows; 049 } 050 051 /** 052 * @see org.kuali.ole.sys.document.web.RenderableElement#isHidden() 053 */ 054 public boolean isHidden() { 055 for(AccountingLineTableRow row : rows) { 056 if (!row.isHidden()) { 057 return false; 058 } 059 } 060 return true; 061 } 062 063 /** 064 * This is not an action block 065 * @see org.kuali.ole.sys.document.web.RenderableElement#isActionBlock() 066 */ 067 public boolean isActionBlock() { 068 return false; 069 } 070 071 /** 072 * Determines if this table is empty of any renderable elements 073 * @return true if this is empty, false otherwise 074 */ 075 public boolean isEmpty() { 076 for (AccountingLineTableRow row : rows) { 077 if (!row.isEmpty()) { 078 return false; 079 } 080 } 081 return true; 082 } 083 084 /** 085 * @see org.kuali.ole.sys.document.web.RenderableElement#renderElement(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag) 086 */ 087 public void renderElement(PageContext pageContext, Tag parentTag, AccountingLineRenderingContext renderingContext) throws JspException { 088 TableRenderer renderer = new TableRenderer(); 089 this.renderingContext = renderingContext; 090 renderer.setTable(this); 091 renderer.render(pageContext, parentTag); 092 renderer.clear(); 093 this.renderingContext = null; 094 } 095 096 /** 097 * Requests that this table render all of its children rows 098 * @param pageContext the page context to render to 099 * @param parentTag the parent tag requesting the rendering 100 * @param accountingLine accounting line getting rendered 101 * @param accountingLineProperty property to the accounting line 102 * @throws JspException thrown when some sort of thing goes wrong 103 */ 104 public void renderChildrenRows(PageContext pageContext, Tag parentTag) throws JspException { 105 for (AccountingLineTableRow row : rows) { 106 row.renderElement(pageContext, parentTag, renderingContext); 107 } 108 } 109 110 /** 111 * @see org.kuali.ole.sys.document.web.RenderableElement#appendFieldNames(java.util.List) 112 * 113 * KRAD Conversion: Customization of the fields - No use of data dictionary 114 */ 115 public void appendFields(List<Field> fields) { 116 for (AccountingLineTableRow row : rows) { 117 row.appendFields(fields); 118 } 119 } 120 121 /** 122 * @see org.kuali.ole.sys.document.web.RenderableElement#populateWithTabIndexIfRequested(int[], int) 123 */ 124 public void populateWithTabIndexIfRequested(int reallyHighIndex) { 125 for (AccountingLineTableRow row : rows) { 126 row.populateWithTabIndexIfRequested(reallyHighIndex); 127 } 128 } 129 130 /** 131 * Adds a row to the bottom of this table's list of rows 132 * @param row the row to add 133 */ 134 public void addRow(AccountingLineTableRow row) { 135 if (rows == null) { 136 rows = new ArrayList<AccountingLineTableRow>(); 137 } 138 rows.add(row); 139 } 140}