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 javax.servlet.jsp.JspException;
19 import javax.servlet.jsp.PageContext;
20 import javax.servlet.jsp.tagext.Tag;
21
22 import org.kuali.rice.kns.web.taglib.html.KNSTextareaTag;
23 import org.springframework.web.util.HtmlUtils;
24
25 /**
26 * Renders a field as a text area
27 */
28 public class TextAreaRenderer extends FieldRendererBase {
29 private KNSTextareaTag tag = new KNSTextareaTag();
30
31 /**
32 * Resets the text area tag
33 * @see org.kuali.ole.sys.document.web.renderers.FieldRendererBase#clear()
34 */
35 public void clear() {
36 super.clear();
37 tag.setPageContext(null);
38 tag.setParent(null);
39 tag.setProperty(null);
40 tag.setValue(null);
41 tag.setTitle(null);
42 tag.setRows(null);
43 tag.setCols(null);
44 tag.setStyleClass(null);
45 tag.setStyleId(null);
46 tag.setTabindex(null);
47 }
48
49 /**
50 * Uses the struts html:textarea tag to render a text area
51 * @see org.kuali.ole.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag)
52 */
53 public void render(PageContext pageContext, Tag parentTag) throws JspException {
54 tag.setPageContext(pageContext);
55 tag.setParent(parentTag);
56 tag.setProperty(getFieldName());
57 tag.setValue(getField().getPropertyValue());
58 tag.setTitle(this.getAccessibleTitle());
59 tag.setRows(Integer.toString(getField().getRows()));
60 tag.setCols(Integer.toString(getField().getCols()));
61 tag.setStyleClass(getField().getStyleClass());
62 tag.setStyleId(getFieldName());
63
64 tag.doStartTag();
65 tag.doEndTag();
66
67 renderQuickFinderIfNecessary(pageContext, parentTag);
68
69 if (isShowError()) {
70 renderErrorIcon(pageContext);
71 }
72 }
73
74 /**
75 * I'll take a quick finder if needed
76 * @see org.kuali.ole.sys.document.web.renderers.FieldRenderer#renderQuickfinder()
77 */
78 public boolean renderQuickfinder() {
79 return true;
80 }
81
82 }