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.bean;
22
23 import org.apache.struts.taglib.TagUtils;
24 import org.apache.struts.util.MessageResources;
25
26 import javax.servlet.jsp.JspException;
27 import javax.servlet.jsp.tagext.TagSupport;
28
29
30
31
32
33
34
35
36 public class ParameterTag extends TagSupport {
37
38
39
40 protected static MessageResources messages =
41 MessageResources.getMessageResources(
42 "org.apache.struts.taglib.bean.LocalStrings");
43
44
45
46
47
48
49
50 protected String id = null;
51
52
53
54
55
56 protected String multiple = null;
57
58
59
60
61 protected String name = null;
62
63
64
65
66
67 protected String value = null;
68
69 public String getId() {
70 return (this.id);
71 }
72
73 public void setId(String id) {
74 this.id = id;
75 }
76
77 public String getMultiple() {
78 return (this.multiple);
79 }
80
81 public void setMultiple(String multiple) {
82 this.multiple = multiple;
83 }
84
85 public String getName() {
86 return (this.name);
87 }
88
89 public void setName(String name) {
90 this.name = name;
91 }
92
93 public String getValue() {
94 return (this.value);
95 }
96
97 public void setValue(String value) {
98 this.value = value;
99 }
100
101
102
103
104
105
106
107
108 public int doStartTag() throws JspException {
109
110 if (multiple == null) {
111 String value = pageContext.getRequest().getParameter(name);
112
113 if ((value == null) && (this.value != null)) {
114 value = this.value;
115 }
116
117 if (value == null) {
118 JspException e =
119 new JspException(messages.getMessage("parameter.get", name));
120
121 TagUtils.getInstance().saveException(pageContext, e);
122 throw e;
123 }
124
125 pageContext.setAttribute(id, value);
126
127 return (SKIP_BODY);
128 }
129
130
131 String[] values = pageContext.getRequest().getParameterValues(name);
132
133 if ((values == null) || (values.length == 0)) {
134 if (this.value != null) {
135 values = new String[] { this.value };
136 }
137 }
138
139 if ((values == null) || (values.length == 0)) {
140 JspException e =
141 new JspException(messages.getMessage("parameter.get", name));
142
143 TagUtils.getInstance().saveException(pageContext, e);
144 throw e;
145 }
146
147 pageContext.setAttribute(id, values);
148
149 return (SKIP_BODY);
150 }
151
152
153
154
155 public void release() {
156 super.release();
157 id = null;
158 multiple = null;
159 name = null;
160 value = null;
161 }
162 }