1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.pluto.tags;
21
22 import javax.portlet.PortletURL;
23 import javax.servlet.jsp.JspException;
24 import javax.servlet.jsp.tagext.TagSupport;
25
26
27 /***
28 ** Supporting class for the <CODE>param</CODE> tag.
29 ** defines a parameter that can be added to a <CODE>actionURL</CODE> or
30 ** a <CODE>renderURL</CODE>
31 ** <BR>The following attributes are mandatory
32 ** <UL>
33 ** <LI><CODE>name</CODE>
34 ** <LI><CODE>value</CODE>
35 ** </UL>
36 **/
37 public class ParamTag extends TagSupport
38 {
39
40 private String name;
41 private String value;
42
43 /***
44 * Processes the <CODE>param</CODE> tag.
45 * @return <CODE>SKIP_BODY</CODE>
46 */
47 public int doStartTag() throws JspException
48 {
49 BasicURLTag urlTag = (BasicURLTag)findAncestorWithClass(this, BasicURLTag.class);
50 if (urlTag == null)
51 {
52 throw new JspException("the 'param' Tag must have actionURL or renderURL as a parent");
53 }
54 PortletURL url = urlTag.getUrl();
55
56 if (getName() != null)
57 {
58 url.setParameter(getName(),getValue());
59 }
60
61 return SKIP_BODY;
62 }
63
64 /***
65 * Returns the name.
66 * @return String
67 */
68 public String getName()
69 {
70 return name;
71 }
72
73 /***
74 * Returns the value.
75 * @return String
76 */
77 public String getValue()
78 {
79 if (value == null)
80 {
81 value = "";
82 }
83 return value;
84 }
85
86 /***
87 * Sets the name.
88 * @param name The name to set
89 */
90 public void setName(String name)
91 {
92 this.name = name;
93 }
94
95 /***
96 * Sets the value.
97 * @param value The value to set
98 */
99 public void setValue(String value)
100 {
101 this.value = value;
102 }
103
104 }