001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: * $Header:$
018: */
019: package org.apache.beehive.netui.tags.html;
020:
021: import org.apache.beehive.netui.tags.AbstractClassicTag;
022: import org.apache.beehive.netui.util.Bundle;
023:
024: import javax.servlet.jsp.JspException;
025: import javax.servlet.jsp.tagext.JspTag;
026: import javax.servlet.jsp.tagext.SimpleTagSupport;
027: import javax.servlet.jsp.tagext.Tag;
028:
029: /**
030: * Configures popup window parameters for parent tags that can open popup windows.
031: * @jsptagref.tagdescription Configures popup window parameters for parent tags that can open popup windows.
032: * @example <pre>
033: * <netui:anchor action="getCityZipFromNestedPageFlow" popup="true">
034: * Get a city and zip code
035: * <netui:configurePopup resizable="false" width="400" height="200">
036: * <netui:retrievePopupOutput tagIdRef="zipCodeField" dataSource="outputFormBean.zipCode" />
037: * <netui:retrievePopupOutput tagIdRef="cityField" dataSource="outputFormBean.city" />
038: * </netui:configurePopup>
039: * </netui:anchor></pre>
040: * @netui:tag name="configurePopup" description="Configures popup window parameters for parent tags that can open popup windows."
041: */
042: public class ConfigurePopup extends AbstractClassicTag {
043: private String _name = "";
044: private Boolean _toolbar = null;
045: private Boolean _location = null;
046: private Boolean _directories = null;
047: private Boolean _status = null;
048: private Boolean _menubar = null;
049: private Boolean _resizable = null;
050: private Boolean _scrollbars = null;
051: private Integer _width = null;
052: private Integer _height = null;
053: private Integer _left = null;
054: private Integer _top = null;
055: private boolean _replace = false;
056: private String _popupFunc;
057: private String _onPopupDone;
058: private boolean _updateFormFields = false;
059:
060: /**
061: * Return the name of the Tag.
062: */
063: public String getTagName() {
064: return "ConfigurePopup";
065: }
066:
067: /**
068: * Sets the JavaScript function to be called when the popup window is closing. If this attribute is not present,
069: * a default function will be generated.
070: * @param onPopupDone the JavaScript function to be called when the popup window is closing.
071: * @jsptagref.attributedescription The JavaScript function to be called when the popup window is closing.
072: * @jsptagref.databindable false
073: * @jsptagref.attributesyntaxvalue <i>string_onPopupDone</i>
074: * @netui:attribute required="false" rtexprvalue="true"
075: * description="The JavaScript function to be called when the popup window is closing."
076: */
077: public void setOnPopupDone(String onPopupDone) {
078: _onPopupDone = onPopupDone;
079: }
080:
081: /**
082: * Sets the JavaScript function to be called to open the popup window. This function overrides the auto-generated
083: * one that is based on the other attributes like <code>resizable</code>, <code>name</code>, etc.
084: * @param popupFunc the JavaScript function to be called to open the popup window.
085: * @jsptagref.attributedescription The JavaScript function to be called to open the popup window.
086: * @jsptagref.databindable false
087: * @jsptagref.attributesyntaxvalue <i>string_popupFunc</i>
088: * @netui:attribute required="false" rtexprvalue="true"
089: * description="The JavaScript function to be called to open the popup window."
090: */
091: public void setPopupFunc(String popupFunc) {
092: _popupFunc = popupFunc;
093: }
094:
095: /**
096: * Sets whether the JavaScript function that opens the popup window should add data
097: * from the form fields to the request.
098: * @param updateFormFields whether the data from the form fields is included in the popup window request.
099: * @jsptagref.attributedescription Whether the data from the form fields is included in the popup window request.
100: * @jsptagref.databindable true
101: * @jsptagref.attributesyntaxvalue <i>string_updateFormFields</i>
102: * @netui:attribute required="false" rtexprvalue="true"
103: * description="Whether the data from the form fields is included in the popup window request."
104: */
105: public void setUpdateFormFields(boolean updateFormFields) {
106: _updateFormFields = updateFormFields;
107: }
108:
109: /**
110: * Sets the name of the popup window.
111: * @param name the name of the popup window.
112: * @jsptagref.attributedescription The name of the popup window.
113: * @jsptagref.databindable true
114: * @jsptagref.attributesyntaxvalue <i>string_name</i>
115: * @netui:attribute required="false" rtexprvalue="true"
116: * description="The name of the popup window."
117: */
118: public void setName(String name) {
119: _name = name;
120: }
121:
122: /**
123: * Sets whether the toolbar is visible in the popup window.
124: * @param toolbar whether the toolbar is visible in the popup window.
125: * @jsptagref.attributedescription Whether the toolbar is visible in the popup window.
126: * @jsptagref.databindable true
127: * @jsptagref.attributesyntaxvalue <i>boolean_toolbar</i>
128: * @netui:attribute required="false" rtexprvalue="true"
129: * description="Whether the toolbar is visible in the popup window."
130: */
131: public void setToolbar(boolean toolbar) {
132: _toolbar = Boolean.valueOf(toolbar);
133: }
134:
135: /**
136: * Sets whether the location (address) bar is visible in the popup window.
137: * @param location whether the location (address) bar is visible in the popup window.
138: * @jsptagref.attributedescription Whether the location (address) bar is visible in the popup window.
139: * @jsptagref.databindable true
140: * @jsptagref.attributesyntaxvalue <i>boolean_location</i>
141: * @netui:attribute required="false" rtexprvalue="true"
142: * description="Whether the location (address) bar is visible in the popup window."
143: */
144: public void setLocation(boolean location) {
145: _location = Boolean.valueOf(location);
146: }
147:
148: /**
149: * Sets whether directory buttons are displayed in the popup window.
150: * @param directories whether directory buttons are displayed in the popup window.
151: * @jsptagref.attributedescription Whether directory buttons are displayed in the popup window.
152: * @jsptagref.databindable true
153: * @jsptagref.attributesyntaxvalue <i>boolean_directories</i>
154: * @netui:attribute required="false" rtexprvalue="true"
155: * description="Whether directory buttons are displayed in the popup window."
156: */
157: public void setDirectories(boolean directories) {
158: _directories = Boolean.valueOf(directories);
159: }
160:
161: /**
162: * Sets whether the status bar is displayed in the popup window.
163: * @param status whether the status bar is displayed in the popup window.
164: * @jsptagref.attributedescription Whether the status bar is displayed in the popup window.
165: * @jsptagref.databindable true
166: * @jsptagref.attributesyntaxvalue <i>boolean_status</i>
167: * @netui:attribute required="false" rtexprvalue="true"
168: * description="Whether the status bar is displayed in the popup window."
169: */
170: public void setStatus(boolean status) {
171: _status = Boolean.valueOf(status);
172: }
173:
174: /**
175: * Sets whether the menu bar is displayed in the popup window.
176: * @param menubar whether the menu bar is displayed in the popup window.
177: * @jsptagref.attributedescription Whether the menu bar is displayed in the popup window.
178: * @jsptagref.databindable true
179: * @jsptagref.attributesyntaxvalue <i>boolean_menubar</i>
180: * @netui:attribute required="false" rtexprvalue="true"
181: * description="Whether the menu bar is displayed in the popup window."
182: */
183: public void setMenubar(boolean menubar) {
184: _menubar = Boolean.valueOf(menubar);
185: }
186:
187: /**
188: * Sets whether the popup window has scroll bars.
189: * @param scrollbars whether the popup window has scroll bars.
190: * @jsptagref.attributedescription Whether the popup window has scroll bars.
191: * @jsptagref.databindable true
192: * @jsptagref.attributesyntaxvalue <i>boolean_scrollbars</i>
193: * @netui:attribute required="false" rtexprvalue="true"
194: * description="Whether the popup window has scroll bars."
195: */
196: public void setScrollbars(boolean scrollbars) {
197: _scrollbars = Boolean.valueOf(scrollbars);
198: }
199:
200: /**
201: * Sets whether the popup window is resizable.
202: * @param resizable whether the popup window is resizable.
203: * @jsptagref.attributedescription Whether the popup window is resizable.
204: * @jsptagref.databindable true
205: * @jsptagref.attributesyntaxvalue <i>boolean_resizable</i>
206: * @netui:attribute required="false" rtexprvalue="true"
207: * description="Whether the popup window is resizable."
208: */
209: public void setResizable(boolean resizable) {
210: _resizable = Boolean.valueOf(resizable);
211: }
212:
213: /**
214: * Sets the width of the popup window.
215: * @param width the width of the popup window.
216: * @jsptagref.attributedescription The width of the popup window.
217: * @jsptagref.databindable true
218: * @jsptagref.attributesyntaxvalue <i>integer_width</i>
219: * @netui:attribute required="false" rtexprvalue="true"
220: * description="The width of the popup window."
221: */
222: public void setWidth(int width) {
223: _width = new Integer(width);
224: }
225:
226: /**
227: * Sets the height of the popup window.
228: * @param height the height of the popup window.
229: * @jsptagref.attributedescription The height of the popup window.
230: * @jsptagref.databindable true
231: * @jsptagref.attributesyntaxvalue <i>integer_height</i>
232: * @netui:attribute required="false" rtexprvalue="true"
233: * description="The height of the popup window."
234: */
235: public void setHeight(int height) {
236: _height = new Integer(height);
237: }
238:
239: /**
240: * Sets the X coordinate of the top left corner of the popup window.
241: * @param left the X coordinate of the top left corner of the popup window.
242: * @jsptagref.attributedescription The X coordinate of the top left corner of the popup window.
243: * @jsptagref.databindable true
244: * @jsptagref.attributesyntaxvalue <i>integer_left</i>
245: * @netui:attribute required="false" rtexprvalue="true"
246: * description="The X coordinate of the top left corner of the popup window."
247: */
248: public void setLeft(int left) {
249: _left = new Integer(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: _top = new Integer(top);
263: }
264:
265: /**
266: * Sets whether the popup window's location will replace the location in the current window's navigation history.
267: * @param replace whether the popup window's location will replace the location in the current window's navigation history.
268: * @jsptagref.attributedescription Whether the popup window's location will replace the location in the current window's navigation history.
269: * @jsptagref.databindable true
270: * @jsptagref.attributesyntaxvalue <i>boolean_replace</i>
271: * @netui:attribute required="false" rtexprvalue="true"
272: * description="Whether the popup window's location will replace the location in the current window's navigation history."
273: */
274: public void setReplace(boolean replace) {
275: _replace = replace;
276: }
277:
278: /**
279: * @throws JspException if a JSP exception has occurred
280: */
281: public int doStartTag() throws JspException {
282: JspTag parentTag = SimpleTagSupport.findAncestorWithClass(this ,
283: IHasPopupSupport.class);
284: if (parentTag == null) {
285: String msg = Bundle
286: .getString("Tags_InvalidConfigurePopupParent");
287: registerTagError(msg, null);
288: reportErrors();
289: } else {
290: PopupSupport popupSupport = ((IHasPopupSupport) parentTag)
291: .getPopupSupport();
292:
293: // if popupSupport is null, then the tag isn't set to open a popup window
294: if (popupSupport != null) {
295: popupSupport.setName(_name);
296: if (_toolbar != null)
297: popupSupport.setToolbar(_toolbar.booleanValue());
298: if (_location != null)
299: popupSupport.setLocation(_location.booleanValue());
300: if (_directories != null)
301: popupSupport.setDirectories(_directories
302: .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
309: .setResizable(_resizable.booleanValue());
310: if (_scrollbars != null)
311: popupSupport.setScrollbars(_scrollbars
312: .booleanValue());
313: if (_width != null)
314: popupSupport.setWidth(_width.intValue());
315: if (_height != null)
316: popupSupport.setHeight(_height.intValue());
317: if (_left != null)
318: popupSupport.setLeft(_left.intValue());
319: if (_top != null)
320: popupSupport.setTop(_top.intValue());
321: popupSupport.setReplace(_replace);
322: popupSupport.setPopupFunc(_popupFunc);
323: popupSupport.setOnPopupDone(_onPopupDone);
324:
325: if (_updateFormFields) {
326: Form form = getNearestForm();
327: String realFormName = form.getRealFormId();
328: form.insureRealId();
329: popupSupport.setFormName(realFormName);
330: }
331: }
332: }
333:
334: localRelease();
335: return EVAL_BODY_INCLUDE;
336: }
337:
338: /**
339: * Release any acquired resources.
340: */
341: protected void localRelease() {
342: _name = "";
343: _toolbar = null;
344: _location = null;
345: _directories = null;
346: _status = null;
347: _menubar = null;
348: _resizable = null;
349: _scrollbars = null;
350: _width = null;
351: _height = null;
352: _left = null;
353: _top = null;
354: _replace = false;
355: _popupFunc = null;
356: _onPopupDone = null;
357: _updateFormFields = false;
358:
359: super.localRelease();
360: }
361:
362: }
|