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