1 /* 2 * The Kuali Financial System, a comprehensive financial management system for higher education. 3 * 4 * Copyright 2005-2014 The Kuali Foundation 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU Affero General Public License as 8 * published by the Free Software Foundation, either version 3 of the 9 * License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Affero General Public License for more details. 15 * 16 * You should have received a copy of the GNU Affero General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 package org.kuali.kfs.sys.document.web.renderers; 20 21 import java.io.IOException; 22 23 import javax.servlet.jsp.JspException; 24 import javax.servlet.jsp.JspWriter; 25 import javax.servlet.jsp.PageContext; 26 import javax.servlet.jsp.tagext.Tag; 27 28 import org.kuali.kfs.sys.document.web.AccountingLineTable; 29 30 /** 31 * Renders a table 32 */ 33 public class TableRenderer implements Renderer { 34 AccountingLineTable table; 35 36 /** 37 * Clears out the table 38 * @see org.kuali.kfs.sys.document.web.renderers.Renderer#clear() 39 */ 40 public void clear() { 41 table = null; 42 } 43 44 /** 45 * 46 * @see org.kuali.kfs.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag) 47 */ 48 public void render(PageContext pageContext, Tag parentTag) throws JspException { 49 JspWriter out = pageContext.getOut(); 50 try { 51 out.write(buildBeginningTableTag()); 52 table.renderChildrenRows(pageContext, parentTag); 53 out.write(buildEndingTableTag()); 54 } 55 catch (IOException ioe) { 56 throw new JspException("Difficulty with rendering inner table", ioe); 57 } 58 } 59 60 /** 61 * Builds the opening tag of the table, ie <table class="datatable"> 62 * @return the String for the opening tag 63 */ 64 protected String buildBeginningTableTag() { 65 return "<table class=\"datatable\">"; 66 } 67 68 /** 69 * Builds the closing tag of the table, ie </table> 70 * @return the String for the closing tag 71 */ 72 protected String buildEndingTableTag() { 73 return "</table>"; 74 } 75 76 /** 77 * Gets the table attribute. 78 * @return Returns the table. 79 */ 80 public AccountingLineTable getTable() { 81 return table; 82 } 83 84 /** 85 * Sets the table attribute value. 86 * @param table The table to set. 87 */ 88 public void setTable(AccountingLineTable table) { 89 this.table = table; 90 } 91 }