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.util.MessageResources;
24
25 import javax.servlet.jsp.JspException;
26 import javax.servlet.jsp.tagext.BodyTagSupport;
27 import javax.servlet.jsp.tagext.Tag;
28
29
30
31
32
33
34
35 public class ParamTag extends BodyTagSupport {
36
37
38
39
40 protected static MessageResources messages =
41 MessageResources.getMessageResources(Constants.Package
42 + ".LocalStrings");
43
44
45
46
47 protected String name = null;
48
49
50
51
52 protected String value = null;
53
54
55
56 public ParamTag() {
57 super();
58 }
59
60 public String getName() {
61 return (this.name);
62 }
63
64 public void setName(String name) {
65 this.name = name;
66 }
67
68 public String getValue() {
69 return (this.value);
70 }
71
72 public void setValue(String value) {
73 this.value = value;
74 }
75
76
77
78
79
80
81 public int doStartTag() throws JspException {
82 return (EVAL_BODY_TAG);
83 }
84
85
86
87
88
89
90 public int doAfterBody() throws JspException {
91 if (this.bodyContent != null) {
92 String value = this.bodyContent.getString().trim();
93 if (value.length() > 0) {
94 this.value = value;
95 }
96 }
97 return (SKIP_BODY);
98 }
99
100
101
102
103
104
105 public int doEndTag() throws JspException {
106 Tag tag = findAncestorWithClass(this, LinkTag.class);
107 if (tag != null) {
108 ((LinkTag)tag).addParameter(this.name, this.value);
109 } else {
110 throw new JspException(messages.getMessage("linkParamTag.linkParam"));
111 }
112 return (EVAL_PAGE);
113 }
114
115
116
117
118 public void release() {
119 super.release();
120 this.name = null;
121 this.value = null;
122 }
123 }