1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.struts.taglib.html;
22
23 import org.apache.struts.taglib.TagUtils;
24
25 import javax.servlet.jsp.JspException;
26
27 /**
28 * Custom tag for input fields of type "hidden".
29 *
30 * @version $Rev: 471754 $ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
31 * $
32 */
33 public class HiddenTag extends BaseFieldTag {
34
35
36 /**
37 * Should the value of this field also be rendered to the response?
38 */
39 protected boolean write = false;
40
41
42
43 /**
44 * Construct a new instance of this tag.
45 */
46 public HiddenTag() {
47 super();
48 this.type = "hidden";
49 }
50
51 public boolean getWrite() {
52 return (this.write);
53 }
54
55 public void setWrite(boolean write) {
56 this.write = write;
57 }
58
59
60
61 /**
62 * Generate the required input tag, followed by the optional rendered
63 * text. Support for <code>write</code> property since Struts 1.1.
64 *
65 * @throws JspException if a JSP exception has occurred
66 */
67 public int doStartTag() throws JspException {
68
69 super.doStartTag();
70
71
72 if (!write) {
73 return (EVAL_BODY_TAG);
74 }
75
76
77
78 String results = null;
79
80 if (value != null) {
81 results = TagUtils.getInstance().filter(value);
82 } else {
83 Object value =
84 TagUtils.getInstance().lookup(pageContext, name, property, null);
85
86 if (value == null) {
87 results = "";
88 } else {
89 results = TagUtils.getInstance().filter(value.toString());
90 }
91 }
92
93 TagUtils.getInstance().write(pageContext, results);
94
95 return (EVAL_BODY_TAG);
96 }
97
98 /**
99 * Release any acquired resources.
100 */
101 public void release() {
102 super.release();
103 write = false;
104 }
105 }