KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2003-2005 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 java.io.IOException JavaDoc;
23
24 import javax.portlet.PortletURL;
25 import javax.servlet.jsp.JspException JavaDoc;
26 import javax.servlet.jsp.JspWriter JavaDoc;
27 import javax.servlet.jsp.PageContext JavaDoc;
28 import javax.servlet.jsp.tagext.TagData JavaDoc;
29 import javax.servlet.jsp.tagext.TagExtraInfo JavaDoc;
30 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
31 import javax.servlet.jsp.tagext.VariableInfo JavaDoc;
32
33 /**
34  * Supporting class for the <CODE>actionURL</CODE> and <CODE>renderURL</CODE> tag.
35  * Creates a url that points to the current Portlet and triggers an action request
36  * with the supplied parameters.
37  *
38  */

39 public abstract class BasicURLTag extends TagSupport JavaDoc
40 {
41
42     public static class TEI extends TagExtraInfo JavaDoc
43     {
44         public VariableInfo JavaDoc[] getVariableInfo(TagData JavaDoc tagData)
45         {
46             VariableInfo JavaDoc vi[] = null;
47             String JavaDoc var = tagData.getAttributeString("var");
48             if (var != null)
49             {
50                 vi = new VariableInfo JavaDoc[1];
51                 vi[0] = new VariableInfo JavaDoc(var, "java.lang.String", true, VariableInfo.AT_BEGIN);
52             }
53             return vi;
54         }
55     }
56
57     protected String JavaDoc portletMode;
58     protected String JavaDoc secure;
59     protected Boolean JavaDoc secureBoolean;
60     protected String JavaDoc windowState;
61     protected PortletURL url;
62     protected String JavaDoc var;
63
64     /**
65      * Processes the <CODE>actionURL</CODE> or <CODE>renderURL</CODE> tag.
66      * @return int
67      */

68     public abstract int doStartTag() throws JspException JavaDoc;
69
70     /**
71      *
72      * @return int
73      */

74     public int doEndTag() throws JspException JavaDoc {
75         if (var == null)
76         {
77             try
78             {
79                 JspWriter JavaDoc writer = pageContext.getOut();
80                 writer.print(url);
81                 writer.flush();
82             }
83             catch (IOException JavaDoc ioe)
84             {
85                 throw new JspException JavaDoc("actionURL/renderURL Tag Exception: cannot write to the output writer.");
86             }
87         } else {
88                 pageContext.setAttribute (var, url.toString(), PageContext.PAGE_SCOPE);
89         }
90         return EVAL_PAGE;
91     }
92
93     /**
94      * Returns the portletMode.
95      * @return String
96      */

97     public String JavaDoc getPortletMode()
98     {
99         return portletMode;
100     }
101
102     /**
103      * @return secure as String
104      */

105     public String JavaDoc getSecure()
106     {
107         return secure;
108     }
109
110     /**
111      * @return secure as Boolean
112      */

113     public boolean getSecureBoolean()
114     {
115         return this.secureBoolean.booleanValue();
116     }
117
118     /**
119      * Returns the windowState.
120      * @return String
121      */

122     public String JavaDoc getWindowState()
123     {
124         return windowState;
125     }
126
127     /**
128      * @return PortletURL
129      */

130     public PortletURL getUrl()
131     {
132         return url;
133     }
134
135     /**
136      * Returns the var.
137      * @return String
138      */

139     public String JavaDoc getVar()
140     {
141         return var;
142     }
143
144     /**
145      * Sets the portletMode.
146      * @param portletMode The portletMode to set
147      */

148     public void setPortletMode(String JavaDoc portletMode)
149     {
150         this.portletMode = portletMode;
151     }
152
153     /**
154      * Sets secure to boolean value of the string
155      * @param secure
156      */

157     public void setSecure(String JavaDoc secure)
158     {
159         this.secure = secure;
160         this.secureBoolean = new Boolean JavaDoc(secure);
161     }
162
163     /**
164      * Sets the windowState.
165      * @param windowState The windowState to set
166      */

167     public void setWindowState(String JavaDoc windowState)
168     {
169         this.windowState = windowState;
170     }
171
172     /**
173      * Sets the url.
174      * @param url The url to set
175      */

176     public void setUrl(PortletURL url)
177     {
178         this.url = url;
179     }
180
181     /**
182      * Sets the var.
183      * @param var The var to set
184      */

185     public void setVar(String JavaDoc var)
186     {
187         this.var = var;
188     }
189 }
190
Popular Tags