KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tags > html > ConfigurePopup


1 /*
2 * Copyright 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 * $Header:$
17 */

18 package org.apache.beehive.netui.tags.html;
19
20 import org.apache.beehive.netui.tags.AbstractClassicTag;
21 import org.apache.beehive.netui.util.Bundle;
22
23 import javax.servlet.jsp.JspException JavaDoc;
24 import javax.servlet.jsp.tagext.JspTag JavaDoc;
25 import javax.servlet.jsp.tagext.SimpleTagSupport JavaDoc;
26
27
28 /**
29  * Configures popup window parameters for parent tags that can open popup windows.
30  * @jsptagref.tagdescription Configures popup window parameters for parent tags that can open popup windows.
31  * @example <pre>
32  * &lt;netui:anchor action="getCityZipFromNestedPageFlow" popup="true">
33  * Get a city and zip code
34  * &lt;netui:configurePopup resizable="false" width="400" height="200">
35  * &lt;netui:retrievePopupOutput tagIdRef="zipCodeField" dataSource="outputFormBean.zipCode" /&gt;
36  * &lt;netui:retrievePopupOutput tagIdRef="cityField" dataSource="outputFormBean.city" /&gt;
37  * &lt;/netui:configurePopup>
38  * &lt;/netui:anchor></pre>
39  * @netui:tag name="configurePopup" description="Configures popup window parameters for parent tags that can open popup windows."
40  */

41 public class ConfigurePopup
42         extends AbstractClassicTag
43 {
44     private String JavaDoc _name = "";
45     private Boolean JavaDoc _toolbar = null;
46     private Boolean JavaDoc _location = null;
47     private Boolean JavaDoc _directories = null;
48     private Boolean JavaDoc _status = null;
49     private Boolean JavaDoc _menubar = null;
50     private Boolean JavaDoc _resizable = null;
51     private Boolean JavaDoc _scrollbars = null;
52     private Integer JavaDoc _width = null;
53     private Integer JavaDoc _height = null;
54     private Integer JavaDoc _left = null;
55     private Integer JavaDoc _top = null;
56     private boolean _replace = false;
57     private String JavaDoc _popupFunc;
58     private String JavaDoc _onPopupDone;
59
60     /**
61      * Return the name of the Tag.
62      */

63     public String JavaDoc getTagName()
64     {
65         return "ConfigurePopup";
66     }
67
68     /**
69      * Sets the JavaScript function to be called when the popup window is closing. If this attribute is not present,
70      * a default function will be generated.
71      * @param onPopupDone the JavaScript function to be called when the popup window is closing.
72      * @jsptagref.attributedescription The JavaScript function to be called when the popup window is closing.
73      * @jsptagref.databindable false
74      * @jsptagref.attributesyntaxvalue <i>string_onPopupDone</i>
75      * @netui:attribute required="false" rtexprvalue="true"
76      * description="The JavaScript function to be called when the popup window is closing."
77      */

78     public void setOnPopupDone(String JavaDoc onPopupDone)
79     {
80         _onPopupDone = onPopupDone;
81     }
82
83     /**
84      * Sets the JavaScript function to be called to open the popup window. This function overrides the auto-generated
85      * one that is based on the other attributes like <code>resizable</code>, <code>name</code>, etc.
86      * @param popupFunc the JavaScript function to be called to open the popup window.
87      * @jsptagref.attributedescription The JavaScript function to be called to open the popup window.
88      * @jsptagref.databindable false
89      * @jsptagref.attributesyntaxvalue <i>string_popupFunc</i>
90      * @netui:attribute required="false" rtexprvalue="true"
91      * description="The JavaScript function to be called to open the popup window."
92      */

93     public void setPopupFunc(String JavaDoc popupFunc)
94     {
95         _popupFunc = popupFunc;
96     }
97
98     /**
99      * Sets the name of the popup window.
100      * @param name the name of the popup window.
101      * @jsptagref.attributedescription The name of the popup window.
102      * @jsptagref.databindable true
103      * @jsptagref.attributesyntaxvalue <i>string_name</i>
104      * @netui:attribute required="false" rtexprvalue="true"
105      * description="The name of the popup window."
106      */

107     public void setName(String JavaDoc name)
108     {
109         _name = name;
110     }
111
112     /**
113      * Sets whether the toolbar is visible in the popup window.
114      * @param toolbar whether the toolbar is visible in the popup window.
115      * @jsptagref.attributedescription Whether the toolbar is visible in the popup window.
116      * @jsptagref.databindable true
117      * @jsptagref.attributesyntaxvalue <i>boolean_toolbar</i>
118      * @netui:attribute required="false" rtexprvalue="true"
119      * description="Whether the toolbar is visible in the popup window."
120      */

121     public void setToolbar(boolean toolbar)
122     {
123         _toolbar = Boolean.valueOf(toolbar);
124     }
125
126     /**
127      * Sets whether the location (address) bar is visible in the popup window.
128      * @param location whether the location (address) bar is visible in the popup window.
129      * @jsptagref.attributedescription Whether the location (address) bar is visible in the popup window.
130      * @jsptagref.databindable true
131      * @jsptagref.attributesyntaxvalue <i>boolean_location</i>
132      * @netui:attribute required="false" rtexprvalue="true"
133      * description="Whether the location (address) bar is visible in the popup window."
134      */

135     public void setLocation(boolean location)
136     {
137         _location = Boolean.valueOf(location);
138     }
139
140     /**
141      * Sets whether directory buttons are displayed in the popup window.
142      * @param directories whether directory buttons are displayed in the popup window.
143      * @jsptagref.attributedescription Whether directory buttons are displayed in the popup window.
144      * @jsptagref.databindable true
145      * @jsptagref.attributesyntaxvalue <i>boolean_directories</i>
146      * @netui:attribute required="false" rtexprvalue="true"
147      * description="Whether directory buttons are displayed in the popup window."
148      */

149     public void setDirectories(boolean directories)
150     {
151         _directories = Boolean.valueOf(directories);
152     }
153
154     /**
155      * Sets whether the status bar is displayed in the popup window.
156      * @param status whether the status bar is displayed in the popup window.
157      * @jsptagref.attributedescription Whether the status bar is displayed in the popup window.
158      * @jsptagref.databindable true
159      * @jsptagref.attributesyntaxvalue <i>boolean_status</i>
160      * @netui:attribute required="false" rtexprvalue="true"
161      * description="Whether the status bar is displayed in the popup window."
162      */

163     public void setStatus(boolean status)
164     {
165         _status = Boolean.valueOf(status);
166     }
167
168     /**
169      * Sets whether the menu bar is displayed in the popup window.
170      * @param menubar whether the menu bar is displayed in the popup window.
171      * @jsptagref.attributedescription Whether the menu bar is displayed in the popup window.
172      * @jsptagref.databindable true
173      * @jsptagref.attributesyntaxvalue <i>boolean_menubar</i>
174      * @netui:attribute required="false" rtexprvalue="true"
175      * description="Whether the menu bar is displayed in the popup window."
176      */

177     public void setMenubar(boolean menubar)
178     {
179         _menubar = Boolean.valueOf(menubar);
180     }
181
182     /**
183      * Sets whether the popup window has scroll bars.
184      * @param scrollbars whether the popup window has scroll bars.
185      * @jsptagref.attributedescription Whether the popup window has scroll bars.
186      * @jsptagref.databindable true
187      * @jsptagref.attributesyntaxvalue <i>boolean_scrollbars</i>
188      * @netui:attribute required="false" rtexprvalue="true"
189      * description="Whether the popup window has scroll bars."
190      */

191     public void setScrollbars(boolean scrollbars)
192     {
193         _scrollbars = Boolean.valueOf(scrollbars);
194     }
195
196     /**
197      * Sets whether the popup window is resizable.
198      * @param resizable whether the popup window is resizable.
199      * @jsptagref.attributedescription Whether the popup window is resizable.
200      * @jsptagref.databindable true
201      * @jsptagref.attributesyntaxvalue <i>boolean_resizable</i>
202      * @netui:attribute required="false" rtexprvalue="true"
203      * description="Whether the popup window is resizable."
204      */

205     public void setResizable(boolean resizable)
206     {
207         _resizable = Boolean.valueOf(resizable);
208     }
209
210     /**
211      * Sets the width of the popup window.
212      * @param width the width of the popup window.
213      * @jsptagref.attributedescription The width of the popup window.
214      * @jsptagref.databindable true
215      * @jsptagref.attributesyntaxvalue <i>integer_width</i>
216      * @netui:attribute required="false" rtexprvalue="true"
217      * description="The width of the popup window."
218      */

219     public void setWidth(int width)
220     {
221         _width = new Integer JavaDoc(width);
222     }
223
224     /**
225      * Sets the height of the popup window.
226      * @param height the height of the popup window.
227      * @jsptagref.attributedescription The height of the popup window.
228      * @jsptagref.databindable true
229      * @jsptagref.attributesyntaxvalue <i>integer_height</i>
230      * @netui:attribute required="false" rtexprvalue="true"
231      * description="The height of the popup window."
232      */

233     public void setHeight(int height)
234     {
235         _height = new Integer JavaDoc(height);
236     }
237
238     /**
239      * Sets the X coordinate of the top left corner of the popup window.
240      * @param left the X coordinate of the top left corner of the popup window.
241      * @jsptagref.attributedescription The X coordinate of the top left corner of the popup window.
242      * @jsptagref.databindable true
243      * @jsptagref.attributesyntaxvalue <i>integer_left</i>
244      * @netui:attribute required="false" rtexprvalue="true"
245      * description="The X coordinate of the top left corner of the popup window."
246      */

247     public void setLeft(int left)
248     {
249         _left = new Integer JavaDoc(left);
250     }
251
252     /**
253      * Sets the Y coordinate of the top left corner of the popup window.
254      * @param top the Y coordinate of the top left corner of the popup window.
255      * @jsptagref.attributedescription The Y coordinate of the top left corner of the popup window.
256      * @jsptagref.databindable true
257      * @jsptagref.attributesyntaxvalue <i>integer_left</i>
258      * @netui:attribute required="false" rtexprvalue="true"
259      * description="The Y coordinate of the top left corner of the popup window."
260      */

261     public void setTop(int top)
262     {
263         _top = new Integer JavaDoc(top);
264     }
265
266     /**
267      * Sets whether the popup window's location will replace the location in the current window's navigation history.
268      * @param replace whether the popup window's location will replace the location in the current window's navigation history.
269      * @jsptagref.attributedescription Whether the popup window's location will replace the location in the current window's navigation history.
270      * @jsptagref.databindable true
271      * @jsptagref.attributesyntaxvalue <i>boolean_replace</i>
272      * @netui:attribute required="false" rtexprvalue="true"
273      * description="Whether the popup window's location will replace the location in the current window's navigation history."
274      */

275     public void setReplace(boolean replace)
276     {
277         _replace = replace;
278     }
279
280     /**
281      * @throws JspException if a JSP exception has occurred
282      */

283     public int doStartTag() throws JspException JavaDoc
284     {
285         JspTag JavaDoc parentTag = SimpleTagSupport.findAncestorWithClass(this, IHasPopupSupport.class);
286         if (parentTag == null) {
287             String JavaDoc msg = Bundle.getString("Tags_InvalidConfigurePopupParent");
288             registerTagError(msg, null);
289             reportErrors();
290         }
291         else {
292             PopupSupport popupSupport = ((IHasPopupSupport) parentTag).getPopupSupport();
293             
294             // if popupSupport is null, then the tag isn't set to open a popup window
295
if (popupSupport != null) {
296                 popupSupport.setName(_name);
297                 if (_toolbar != null)
298                     popupSupport.setToolbar(_toolbar.booleanValue());
299                 if (_location != null)
300                     popupSupport.setLocation(_location.booleanValue());
301                 if (_directories != null)
302                     popupSupport.setDirectories(_directories.booleanValue());
303                 if (_status != null)
304                     popupSupport.setStatus(_status.booleanValue());
305                 if (_menubar != null)
306                     popupSupport.setMenubar(_menubar.booleanValue());
307                 if (_resizable != null)
308                     popupSupport.setResizable(_resizable.booleanValue());
309                 if (_scrollbars != null)
310                     popupSupport.setScrollbars(_scrollbars.booleanValue());
311                 if (_width != null)
312                     popupSupport.setWidth(_width.intValue());
313                 if (_height != null)
314                     popupSupport.setHeight(_height.intValue());
315                 if (_left != null)
316                     popupSupport.setLeft(_left.intValue());
317                 if (_top != null)
318                     popupSupport.setTop(_top.intValue());
319                 popupSupport.setReplace(_replace);
320                 popupSupport.setPopupFunc(_popupFunc);
321                 popupSupport.setOnPopupDone(_onPopupDone);
322             }
323         }
324
325         localRelease();
326         return EVAL_BODY_INCLUDE;
327     }
328
329     /**
330      * Release any acquired resources.
331      */

332     protected void localRelease()
333     {
334         _name = "";
335         _toolbar = null;
336         _location = null;
337         _directories = null;
338         _status = null;
339         _menubar = null;
340         _resizable = null;
341         _scrollbars = null;
342         _width = null;
343         _height = null;
344         _left = null;
345         _top = null;
346         _replace = false;
347         _popupFunc = null;
348         _onPopupDone = null;
349
350         super.localRelease();
351     }
352
353 }
354
Popular Tags