1
2
3
4
5
6
7
8
9
10
11
12
13
14
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.apache.commons.lang.StringUtils;
26 import org.apache.struts.taglib.html.HiddenTag;
27 import org.springframework.web.util.HtmlUtils;
28
29
30
31
32 public class DynamicNameLabelRenderer implements Renderer {
33 private String fieldName = null;
34 private String fieldValue = null;
35 private HiddenTag valuePersistingTag = new HiddenTag();
36
37
38
39
40 public void clear() {
41 fieldName = null;
42 fieldValue = null;
43
44 valuePersistingTag.setPageContext(null);
45 valuePersistingTag.setParent(null);
46 valuePersistingTag.setProperty(null);
47 valuePersistingTag.setValue(null);
48 }
49
50
51
52
53
54 public void render(PageContext pageContext, Tag parentTag) throws JspException {
55 JspWriter out = pageContext.getOut();
56 try {
57 out.write("<br />");
58 out.write("<div id=\""+fieldName+".div\" class=\"fineprint\">");
59 if (!StringUtils.isBlank(fieldValue)) {
60 out.write(fieldValue);
61 }
62 out.write("</div>");
63
64 if (!StringUtils.isBlank(fieldValue)) {
65 renderValuePersistingTag(pageContext, parentTag);
66 }
67 }
68 catch (IOException ioe) {
69 throw new JspException("Difficulty rendering a dynamic field label", ioe);
70 }
71 }
72
73
74
75
76
77
78 protected void renderValuePersistingTag(PageContext pageContext, Tag parentTag) throws JspException {
79 valuePersistingTag.setPageContext(pageContext);
80 valuePersistingTag.setParent(parentTag);
81 valuePersistingTag.setProperty(fieldName);
82 valuePersistingTag.setValue(fieldValue);
83
84 valuePersistingTag.doStartTag();
85 valuePersistingTag.doEndTag();
86 }
87
88
89
90
91
92 public String getFieldName() {
93 return fieldName;
94 }
95
96
97
98
99
100 public void setFieldName(String fieldName) {
101 this.fieldName = fieldName;
102 }
103
104
105
106
107
108 public String getFieldValue() {
109 return fieldValue;
110 }
111
112
113
114
115
116 public void setFieldValue(String fieldValue) {
117 this.fieldValue = fieldValue;
118 }
119 }