KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > pluto > tags > ParamTag


1 /*
2  * Copyright 2003,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17
18  */

19
20 package org.apache.pluto.tags;
21
22 import javax.portlet.PortletURL;
23 import javax.servlet.jsp.JspException JavaDoc;
24 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
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 JavaDoc
38 {
39
40     private String JavaDoc name;
41     private String JavaDoc value;
42
43     /**
44      * Processes the <CODE>param</CODE> tag.
45      * @return <CODE>SKIP_BODY</CODE>
46      */

47     public int doStartTag() throws JspException JavaDoc
48     {
49         BasicURLTag urlTag = (BasicURLTag)findAncestorWithClass(this, BasicURLTag.class);
50         if (urlTag == null)
51         {
52             throw new JspException JavaDoc("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 JavaDoc getName()
69     {
70         return name;
71     }
72
73     /**
74      * Returns the value.
75      * @return String
76      */

77     public String JavaDoc 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 JavaDoc 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 JavaDoc value)
100     {
101         this.value = value;
102     }
103
104 }
105
Popular Tags