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.PageContext;
22 import javax.servlet.jsp.tagext.Tag;
23
24 /**
25 * Don't you love it when you've got to write silly code, just because of some arbitrary rule within the
26 * system? Don't you love it even more when _you_ are the one who created that arbitrary rule? All
27 * tag rendering occurs through Renderer implementations - even Strings, okay?
28 */
29 public class StringRenderer implements Renderer {
30 private String stringToRender;
31
32 /**
33 * Clears out the stringToRender
34 * @see org.kuali.ole.sys.document.web.renderers.Renderer#clear()
35 */
36 public void clear() {
37 stringToRender = null;
38 }
39
40 /**
41 * Renders stringToRender
42 * @see org.kuali.ole.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag)
43 */
44 public void render(PageContext pageContext, Tag parentTag) throws JspException {
45 if (stringToRender != null) {
46 try {
47 pageContext.getOut().write(stringToRender);
48 }
49 catch (IOException ioe) {
50 new JspException("Difficulty rendering...oh dear...difficulty rendering a plain String. That's just sad.", ioe);
51 }
52 }
53 }
54
55 /**
56 * Gets the stringToRender attribute.
57 * @return Returns the stringToRender.
58 */
59 public String getStringToRender() {
60 return stringToRender;
61 }
62
63 /**
64 * Sets the stringToRender attribute value.
65 * @param stringToRender The stringToRender to set.
66 */
67 public void setStringToRender(String stringToRender) {
68 this.stringToRender = stringToRender;
69 }
70
71 }