View Javadoc
1   /*
2    * Copyright 2008 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.sys.document.web.renderers;
17  
18  import java.io.IOException;
19  
20  import javax.servlet.jsp.JspException;
21  import javax.servlet.jsp.JspWriter;
22  import javax.servlet.jsp.PageContext;
23  import javax.servlet.jsp.tagext.Tag;
24  
25  import org.kuali.ole.sys.document.web.AccountingLineTable;
26  
27  /**
28   * Renders a table
29   */
30  public class TableRenderer implements Renderer {
31      AccountingLineTable table;
32  
33      /**
34       * Clears out the table
35       * @see org.kuali.ole.sys.document.web.renderers.Renderer#clear()
36       */
37      public void clear() {
38          table = null;
39      }
40  
41      /**
42       * 
43       * @see org.kuali.ole.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag)
44       */
45      public void render(PageContext pageContext, Tag parentTag) throws JspException {
46          JspWriter out = pageContext.getOut();
47          try {
48              out.write(buildBeginningTableTag());
49              table.renderChildrenRows(pageContext, parentTag);
50              out.write(buildEndingTableTag());
51          }
52          catch (IOException ioe) {
53              throw new JspException("Difficulty with rendering inner table", ioe);
54          }
55      }
56      
57      /**
58       * Builds the opening tag of the table, ie <table class="datatable">
59       * @return the String for the opening tag
60       */
61      protected String buildBeginningTableTag() {
62          return "<table class=\"datatable\">";
63      }
64      
65      /**
66       * Builds the closing tag of the table, ie </table>
67       * @return the String for the closing tag
68       */
69      protected String buildEndingTableTag() {
70          return "</table>";
71      }
72  
73      /**
74       * Gets the table attribute. 
75       * @return Returns the table.
76       */
77      public AccountingLineTable getTable() {
78          return table;
79      }
80  
81      /**
82       * Sets the table attribute value.
83       * @param table The table to set.
84       */
85      public void setTable(AccountingLineTable table) {
86          this.table = table;
87      }
88  }