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  /**
26   * Renders the footer of an accounting line table
27   */
28  public class AccountingLineTableFooterRenderer implements Renderer {
29  
30      /**
31       * There's nothing to clear for pooling for this renderer
32       * @see org.kuali.ole.sys.document.web.renderers.Renderer#clear()
33       */
34      public void clear() {
35          // naught to do
36      }
37  
38      /**
39       * Renders the table footer
40       * @see org.kuali.ole.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag)
41       */
42      public void render(PageContext pageContext, Tag parentTag) throws JspException {
43          JspWriter out = pageContext.getOut();
44          
45          try {
46              out.write(buildTableEnd());
47              out.write(buildKualiElementsNotifier());
48              out.write(buildDivEnd());
49          }
50          catch (IOException ioe) {
51              throw new JspException("Difficulty rendering accounting line table footer", ioe);
52          }
53      }
54  
55      /**
56       * Builds the closing of the table
57       * @return the closing of the table expressed in HTML
58       */
59      protected String buildTableEnd() {
60          return "</table>\n";
61      }
62      
63      /**
64       * Builds the script that figures out all the KualiForm.eleemnts stuff
65       * @return that strange script, expressed in HTML
66       */
67      protected String buildKualiElementsNotifier() {
68          StringBuilder notifier = new StringBuilder();
69          notifier.append("<SCRIPT type=\"text/javascript\">\n");
70          notifier.append("\tvar kualiForm = document.forms['KualiForm'];\n");
71          notifier.append("\tvar kualiElements = kualiForm.elements;\n");
72          notifier.append("</SCRIPT>\n");
73          return notifier.toString();
74      }
75      
76      /**
77       * Builds the close of the tab-container div
78       * @return the close of the div expressed as HTML
79       */
80      protected String buildDivEnd() {
81          return "</div>\n";
82      }
83  }