001 /*
002 * Copyright 2011 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 */
016 package org.kuali.kfs.sys.document.web.renderers;
017
018 import java.io.IOException;
019
020 import javax.servlet.jsp.JspException;
021 import javax.servlet.jsp.JspWriter;
022 import javax.servlet.jsp.PageContext;
023 import javax.servlet.jsp.tagext.Tag;
024
025 /**
026 * Renders the footer of an accounting line table
027 */
028 public class AccountingLineTableFooterRenderer implements Renderer {
029
030 /**
031 * There's nothing to clear for pooling for this renderer
032 * @see org.kuali.kfs.sys.document.web.renderers.Renderer#clear()
033 */
034 public void clear() {
035 // naught to do
036 }
037
038 /**
039 * Renders the table footer
040 * @see org.kuali.kfs.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag)
041 */
042 public void render(PageContext pageContext, Tag parentTag) throws JspException {
043 JspWriter out = pageContext.getOut();
044
045 try {
046 out.write(buildTableEnd());
047 out.write(buildKualiElementsNotifier());
048 out.write(buildDivEnd());
049 }
050 catch (IOException ioe) {
051 throw new JspException("Difficulty rendering accounting line table footer", ioe);
052 }
053 }
054
055 /**
056 * Builds the closing of the table
057 * @return the closing of the table expressed in HTML
058 */
059 protected String buildTableEnd() {
060 return "</table>\n";
061 }
062
063 /**
064 * Builds the script that figures out all the KualiForm.eleemnts stuff
065 * @return that strange script, expressed in HTML
066 */
067 protected String buildKualiElementsNotifier() {
068 StringBuilder notifier = new StringBuilder();
069 notifier.append("<SCRIPT type=\"text/javascript\">\n");
070 notifier.append("\tvar kualiForm = document.forms['KualiForm'];\n");
071 notifier.append("\tvar kualiElements = kualiForm.elements;\n");
072 notifier.append("</SCRIPT>\n");
073 return notifier.toString();
074 }
075
076 /**
077 * Builds the close of the tab-container div
078 * @return the close of the div expressed as HTML
079 */
080 protected String buildDivEnd() {
081 return "</div>\n";
082 }
083 }