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.AccountingLineTableRow;
26
27 /**
28 * Renders a row within a table
29 */
30 public class TableRowRenderer implements Renderer {
31 private AccountingLineTableRow row;
32
33 /**
34 * Resets the table row.
35 * @see org.kuali.ole.sys.document.web.renderers.Renderer#clear()
36 */
37 public void clear() {
38 row = 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 if (row.getChildCellCount() > 0) {
49 out.write(buildBeginningRowTag());
50 row.renderChildrenCells(pageContext, parentTag);
51 out.write(buildEndingRowTag());
52 }
53 }
54 catch (IOException ioe) {
55 throw new JspException("Could not render table row", ioe);
56 }
57 }
58
59 /**
60 *
61 * @return
62 */
63 protected String buildBeginningRowTag() {
64 return "<tr>";
65 }
66
67 /**
68 *
69 * @return
70 */
71 protected String buildEndingRowTag() {
72 return "</tr>";
73 }
74
75 /**
76 * Gets the row attribute.
77 * @return Returns the row.
78 */
79 public AccountingLineTableRow getRow() {
80 return row;
81 }
82
83 /**
84 * Sets the row attribute value.
85 * @param row The row to set.
86 */
87 public void setRow(AccountingLineTableRow row) {
88 this.row = row;
89 }
90 }