Source Code Cross Referenced for JavaScriptWindow.java in  » Development » ivatamasks » com » ivata » mask » web » javascript » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Development » ivatamasks » com.ivata.mask.web.javascript 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2001 - 2005 ivata limited.
003:         * All rights reserved.
004:         * -----------------------------------------------------------------------------
005:         * ivata masks may be redistributed under the GNU General public
006:         * License as published by the Free Software Foundation;
007:         * version 2 of the License.
008:         *
009:         * These programs are free software; you can redistribute them and/or
010:         * modify them under the terms of the GNU General public License
011:         * as published by the Free Software Foundation; version 2 of the License.
012:         *
013:         * These programs are distributed in the hope that they will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016:         *
017:         * See the GNU General public License in the file LICENSE.txt for more
018:         * details.
019:         *
020:         * If you would like a copy of the GNU General public License write to
021:         *
022:         * Free Software Foundation, Inc.
023:         * 59 Temple Place - Suite 330
024:         * Boston, MA 02111-1307, USA.
025:         *
026:         *
027:         * To arrange commercial support and licensing, contact ivata at
028:         *                  http://www.ivata.com/contact.jsp
029:         * -----------------------------------------------------------------------------
030:         * $Log: JavaScriptWindow.java,v $
031:         * Revision 1.5  2005/10/11 18:54:07  colinmacleod
032:         * Fixed some checkstyle and javadoc issues.
033:         *
034:         * Revision 1.4  2005/10/02 14:06:33  colinmacleod
035:         * Added/improved log4j logging.
036:         *
037:         * Revision 1.3  2005/04/09 18:04:18  colinmacleod
038:         * Changed copyright text to GPL v2 explicitly.
039:         *
040:         * Revision 1.2  2005/03/10 10:28:26  colinmacleod
041:         * Fixed for tomcat4.
042:         * Now uses getAttribute and only in page context.
043:         * (Was findAttribute before.)
044:         *
045:         * Revision 1.1  2005/01/06 23:00:31  colinmacleod
046:         * Moved up a version number.
047:         * Changed copyright notices to 2005.
048:         * Updated the documentation:
049:         *   - started working on multiproject:site docu.
050:         *   - changed the logo.
051:         * Added checkstyle and fixed LOADS of style issues.
052:         * Added separate thirdparty subproject.
053:         * Added struts (in web), util and webgui (in webtheme) from ivata op.
054:         *
055:         * Revision 1.4  2004/12/23 21:01:31  colinmacleod
056:         * Updated Struts to v1.2.4.
057:         * Changed base classes to use ivata masks.
058:         *
059:         * Revision 1.3  2004/11/12 15:57:21  colinmacleod
060:         * Removed dependencies on SSLEXT.
061:         * Moved Persistence classes to ivata masks.
062:         *
063:         * Revision 1.2  2004/03/21 21:16:35  colinmacleod
064:         * Shortened name to ivata op.
065:         *
066:         * Revision 1.1.1.1  2004/01/27 20:59:38  colinmacleod
067:         * Moved ivata op to SourceForge.
068:         *
069:         * Revision 1.3  2004/01/19 21:14:23  colin
070:         * Updated for Struts/SSLEXT v1.10
071:         *
072:         * Revision 1.2  2003/10/16 15:43:03  jano
073:         * Fixes problems with building and some problems with splitting to subprojects
074:         *
075:         * Revision 1.1.1.1  2003/10/13 20:49:27  colin
076:         * Restructured portal into subprojects
077:         *
078:         * Revision 1.3  2003/06/10 06:07:18  peter
079:         * last change was a mistake... changed to normal quotes
080:         *
081:         * Revision 1.1  2003/02/24 19:33:33  colin
082:         * Moved to new subproject.
083:         *
084:         * Revision 1.6  2003/02/18 13:13:23  colin
085:         * reverted to single quotes for pop-ups
086:         *
087:         * Revision 1.5  2003/02/18 11:13:15  colin
088:         * switched double/single quotes
089:         *
090:         * Revision 1.4  2003/02/04 17:43:46  colin
091:         * copyright notice
092:         *
093:         * Revision 1.3  2003/01/27 08:19:08  colin
094:         * updated for SSLEXT
095:         *
096:         * Revision 1.2  2003/01/18 20:20:38  colin
097:         * changed error messages to alerts to make them easier to find.
098:         *
099:         * Revision 1.1  2002/06/21 11:58:37  colin
100:         * restructured com.ivata.mask.jsp into separate
101:         * sub-categories: format, JavaScript, theme and tree.
102:         * -----------------------------------------------------------------------------
103:         */
104:        package com.ivata.mask.web.javascript;
105:
106:        import org.apache.log4j.Logger;
107:
108:        import java.net.MalformedURLException;
109:        import java.util.Map;
110:        import javax.servlet.jsp.PageContext;
111:        import org.apache.struts.taglib.TagUtils;
112:
113:        /**
114:         * <p>
115:         * <b>IMPORTANT: </b> the code generated by this class uses double quoted
116:         * strings. That means, if you include the output in an <i>HTML </i> tag
117:         * attribute, you should use single quotes for the HTML attribute.
118:         * </p>
119:         *
120:         * <p>
121:         * Creates a new window using JavaScript. To use this class, set the attributes
122:         * of the window by using the setter methods of this class, then call
123:         * {@link #toString() toString()}to generate the JavaScript.
124:         * </p>
125:         *
126:         * <p>
127:         * You must set the URL and the frame name before calling {@link#toString()
128:         * toString()}.
129:         * </p>
130:         *
131:         * @since ivata masks 0.4 (2002-05-18)
132:         * @author Colin MacLeod
133:         * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
134:         * @version $Revision: 1.5 $
135:         */
136:        public final class JavaScriptWindow {
137:            /**
138:             * Logger for this class.
139:             */
140:            private static final Logger logger = Logger
141:                    .getLogger(JavaScriptWindow.class);
142:
143:            /**
144:             * <p>
145:             * Stores the fame name of the new window.
146:             * </p>
147:             */
148:            private String frameName = null;
149:            /**
150:             * <p>
151:             * Stores whether or not the window has a menu bar. The default setting is
152:             * <code>false</code>.
153:             * </p>
154:             */
155:            private boolean hasMenuBar = false;
156:            /**
157:             * <p>
158:             * Stores whether or not the window has scroll bars. The default setting is
159:             * <code>true</code>.
160:             * </p>
161:             */
162:            private boolean hasScrollBars = true;
163:            /**
164:             * <p>
165:             * Stores whether or not the window has a toolbar. The default setting is
166:             * <code>false</code>.
167:             * </p>
168:             */
169:            private boolean hasToolBar = false;
170:            /**
171:             * <p>
172:             * Stores the height of the window.
173:             * </p>
174:             */
175:            private int height;
176:            /**
177:             * <p>
178:             * Stores whether or not the window can be resized. The default setting is
179:             * <code>true</code>.
180:             * </p>
181:             */
182:            private boolean isResizable = true;
183:            /**
184:             * <p>
185:             * Set this value to specify the application-specific path (beginning with a
186:             * '/') which the new window will show.
187:             * </p>
188:             */
189:            private String page = null;
190:            /**
191:             * <p>
192:             * Used to calculate the URL with the <code>SecureRequestUtils</code> from
193:             * <strong>Struts </strong>.
194:             * </p>
195:             */
196:            private PageContext pageContext = null;
197:            /**
198:             * <p>
199:             * Specifies parameters for the page this window shows.
200:             * </p>
201:             *
202:             * @see TagUtils.getInstance().computeURL
203:             */
204:            private Map params = null;
205:            /**
206:             * <p>
207:             * Specifies the name of a <code>java.util.Map</code> instance in the page
208:             * context which is used to specify parameters for the page this window
209:             * shows.
210:             * </p>
211:             *
212:             * @see TagUtils.getInstance().computeURL.
213:             */
214:            private String paramsName = null;
215:            /**
216:             * <p>
217:             * Stores the width of the window.
218:             * </p>
219:             */
220:            private int width;
221:            /**
222:             * <p>
223:             * Stores the name of a JavaScript object name for the new window.
224:             * </p>
225:             */
226:            private String windowName = null;
227:
228:            /**
229:             * Private helper to create a pop-up (alert) window with a message.
230:             *
231:             * @param message
232:             *            message to display in a pop-up window.
233:             * @return JavaScript for appropriate pop-up.
234:             */
235:            private String alertError(final String message) {
236:                if (logger.isDebugEnabled()) {
237:                    logger.debug("alertError(String message = " + message
238:                            + ") - start");
239:                }
240:
241:                String returnString = "alert(\"ERROR in JavaScriptWindow: "
242:                        + message + "\");";
243:                if (logger.isDebugEnabled()) {
244:                    logger.debug("alertError(String) - end - return value = "
245:                            + returnString);
246:                }
247:                return returnString;
248:            }
249:
250:            /**
251:             * <p>
252:             * Get the fame name of the new window.
253:             * </p>
254:             *
255:             * @return the fame name of the new window.
256:             */
257:            public String getFrameName() {
258:                if (logger.isDebugEnabled()) {
259:                    logger.debug("getFrameName() - start");
260:                }
261:
262:                if (logger.isDebugEnabled()) {
263:                    logger.debug("getFrameName() - end - return value = "
264:                            + frameName);
265:                }
266:                return frameName;
267:            }
268:
269:            /**
270:             * <p>
271:             * Get whether or not the window has a menu bar. The default setting is
272:             * <code>false</code>.
273:             * </p>
274:             *
275:             * @return <code>true</code> if the window has a menu bar, otherwise
276:             *         <code>false</code>.
277:             */
278:            public boolean getHasMenuBar() {
279:                if (logger.isDebugEnabled()) {
280:                    logger.debug("getHasMenuBar() - start");
281:                }
282:
283:                if (logger.isDebugEnabled()) {
284:                    logger.debug("getHasMenuBar() - end - return value = "
285:                            + hasMenuBar);
286:                }
287:                return hasMenuBar;
288:            }
289:
290:            /**
291:             * <p>
292:             * Get whether or not the window has scroll bars. The default setting is
293:             * <code>true</code>.
294:             * </p>
295:             *
296:             * @return <code>true</code> if the window has scroll bars, otherwise
297:             *         <code>false</code>.
298:             */
299:            public boolean getHasScrollBars() {
300:                if (logger.isDebugEnabled()) {
301:                    logger.debug("getHasScrollBars() - start");
302:                }
303:
304:                if (logger.isDebugEnabled()) {
305:                    logger.debug("getHasScrollBars() - end - return value = "
306:                            + hasScrollBars);
307:                }
308:                return hasScrollBars;
309:            }
310:
311:            /**
312:             * <p>
313:             * Get whether or not the window has a tool bar. The default setting is
314:             * <code>true</code>.
315:             * </p>
316:             *
317:             * @return <code>true</code> if the window has a tool bar, otherwise
318:             *         <code>false</code>.
319:             */
320:            public boolean getHasToolBar() {
321:                if (logger.isDebugEnabled()) {
322:                    logger.debug("getHasToolBar() - start");
323:                }
324:
325:                if (logger.isDebugEnabled()) {
326:                    logger.debug("getHasToolBar() - end - return value = "
327:                            + hasToolBar);
328:                }
329:                return hasToolBar;
330:            }
331:
332:            /**
333:             * <p>
334:             * Get the height of the window.
335:             * </p>
336:             *
337:             * @return the height of the window.
338:             */
339:            public int getHeight() {
340:                if (logger.isDebugEnabled()) {
341:                    logger.debug("getHeight() - start");
342:                }
343:
344:                if (logger.isDebugEnabled()) {
345:                    logger
346:                            .debug("getHeight() - end - return value = "
347:                                    + height);
348:                }
349:                return height;
350:            }
351:
352:            /**
353:             * <p>
354:             * Get whether or not the window can be resized. The default setting is
355:             * <code>true</code>.
356:             * </p>
357:             *
358:             * @return <code>true</code> if the window has can be resized, otherwise
359:             *         <code>false</code>.
360:             */
361:            public boolean getIsResizable() {
362:                if (logger.isDebugEnabled()) {
363:                    logger.debug("getIsResizable() - start");
364:                }
365:
366:                if (logger.isDebugEnabled()) {
367:                    logger.debug("getIsResizable() - end - return value = "
368:                            + isResizable);
369:                }
370:                return isResizable;
371:            }
372:
373:            /**
374:             * <p>
375:             * Set this value to specify the application-specific path (beginning with a
376:             * '/') which the new window will show.
377:             * </p>
378:             *
379:             * @return the current value of page.
380:             */
381:            public String getPage() {
382:                if (logger.isDebugEnabled()) {
383:                    logger.debug("getPage() - start");
384:                }
385:
386:                if (logger.isDebugEnabled()) {
387:                    logger.debug("getPage() - end - return value = " + page);
388:                }
389:                return page;
390:            }
391:
392:            /**
393:             * <p>
394:             * Specifies parameters for the page this window shows.
395:             * </p>
396:             *
397:             * @see TagUtils.getInstance().computeURL
398:             * @return the current value of parameters.
399:             */
400:            public Map getParams() {
401:                if (logger.isDebugEnabled()) {
402:                    logger.debug("getParams() - start");
403:                }
404:
405:                if (logger.isDebugEnabled()) {
406:                    logger
407:                            .debug("getParams() - end - return value = "
408:                                    + params);
409:                }
410:                return params;
411:            }
412:
413:            /**
414:             * <p>
415:             * Specifies the name of a <code>java.util.Map</code> instance in the page
416:             * context which is used to specify parameters for the page this window
417:             * shows.
418:             * </p>
419:             *
420:             * @see TagUtils.getInstance().computeURL.
421:             *
422:             * @return the current value of paramsName.
423:             */
424:            public String getParamsName() {
425:                if (logger.isDebugEnabled()) {
426:                    logger.debug("getParamsName() - start");
427:                }
428:
429:                if (logger.isDebugEnabled()) {
430:                    logger.debug("getParamsName() - end - return value = "
431:                            + paramsName);
432:                }
433:                return paramsName;
434:            }
435:
436:            /**
437:             * <p>
438:             * Get the width of the window.
439:             * </p>
440:             *
441:             * @return the width of the window.
442:             */
443:            public int getWidth() {
444:                if (logger.isDebugEnabled()) {
445:                    logger.debug("getWidth() - start");
446:                }
447:
448:                if (logger.isDebugEnabled()) {
449:                    logger.debug("getWidth() - end - return value = " + width);
450:                }
451:                return width;
452:            }
453:
454:            /**
455:             * <p>
456:             * Get a JavaScript object name for the new window.
457:             * </p>
458:             *
459:             * @return a JavaScript object name for the new window.
460:             */
461:            public String getWindowName() {
462:                if (logger.isDebugEnabled()) {
463:                    logger.debug("getWindowName() - start");
464:                }
465:
466:                if (logger.isDebugEnabled()) {
467:                    logger.debug("getWindowName() - end - return value = "
468:                            + windowName);
469:                }
470:                return windowName;
471:            }
472:
473:            /**
474:             * <p>
475:             * Set the fame name of the new window.
476:             * </p>
477:             *
478:             * @param frameNameParam
479:             *            the new value of the fame name of the new window.
480:             */
481:            public void setFrameName(final String frameNameParam) {
482:                if (logger.isDebugEnabled()) {
483:                    logger.debug("setFrameName(String frameNameParam = "
484:                            + frameNameParam + ") - start");
485:                }
486:
487:                this .frameName = frameNameParam;
488:
489:                if (logger.isDebugEnabled()) {
490:                    logger.debug("setFrameName(String) - end");
491:                }
492:            }
493:
494:            /**
495:             * <p>
496:             * Set whether or not the window has a menu bar. The default setting is
497:             * <code>false</code>.
498:             * </p>
499:             *
500:             * @param hasMenuBarParam
501:             *            set to <code>true</code> if the window has a menu bar,
502:             *            otherwise <code>false</code>.
503:             */
504:            public void setHasMenuBar(final boolean hasMenuBarParam) {
505:                if (logger.isDebugEnabled()) {
506:                    logger.debug("setHasMenuBar(boolean hasMenuBarParam = "
507:                            + hasMenuBarParam + ") - start");
508:                }
509:
510:                this .hasMenuBar = hasMenuBarParam;
511:
512:                if (logger.isDebugEnabled()) {
513:                    logger.debug("setHasMenuBar(boolean) - end");
514:                }
515:            }
516:
517:            /**
518:             * <p>
519:             * Set whether or not the window has scroll bars. The default setting is
520:             * <code>true</code>.
521:             * </p>
522:             *
523:             * @param hasScrollBarsParam
524:             *            set to <code>true</code> if the window has scroll bars,
525:             *            otherwise <code>false</code>.
526:             */
527:            public void setHasScrollBars(final boolean hasScrollBarsParam) {
528:                if (logger.isDebugEnabled()) {
529:                    logger
530:                            .debug("setHasScrollBars(boolean hasScrollBarsParam = "
531:                                    + hasScrollBarsParam + ") - start");
532:                }
533:
534:                this .hasScrollBars = hasScrollBarsParam;
535:
536:                if (logger.isDebugEnabled()) {
537:                    logger.debug("setHasScrollBars(boolean) - end");
538:                }
539:            }
540:
541:            /**
542:             * <p>
543:             * Set whether or not the window has a tool bar. The default setting is
544:             * <code>true</code>.
545:             * </p>
546:             *
547:             * @param hasToolBarParam
548:             *            set to <code>true</code> if the window has a tool bar,
549:             *            otherwise <code>false</code>.
550:             */
551:            public void setHasToolBar(final boolean hasToolBarParam) {
552:                if (logger.isDebugEnabled()) {
553:                    logger.debug("setHasToolBar(boolean hasToolBarParam = "
554:                            + hasToolBarParam + ") - start");
555:                }
556:
557:                this .hasToolBar = hasToolBarParam;
558:
559:                if (logger.isDebugEnabled()) {
560:                    logger.debug("setHasToolBar(boolean) - end");
561:                }
562:            }
563:
564:            /**
565:             * <p>
566:             * Set the height of the window. The default setting is <code>450</code>.
567:             * </p>
568:             *
569:             * @param heightParam
570:             *            the new height of the window.
571:             */
572:            public void setHeight(final int heightParam) {
573:                if (logger.isDebugEnabled()) {
574:                    logger.debug("setHeight(int heightParam = " + heightParam
575:                            + ") - start");
576:                }
577:
578:                this .height = heightParam;
579:
580:                if (logger.isDebugEnabled()) {
581:                    logger.debug("setHeight(int) - end");
582:                }
583:            }
584:
585:            /**
586:             * <p>
587:             * Set whether or not the window can be resized. The default setting is
588:             * <code>true</code>.
589:             * </p>
590:             *
591:             * @param isResizableParam
592:             *            set to <code>true</code> if the window has can be resized,
593:             *            otherwise <code>false</code>.
594:             */
595:            public void setIsResizable(final boolean isResizableParam) {
596:                if (logger.isDebugEnabled()) {
597:                    logger.debug("setIsResizable(boolean isResizableParam = "
598:                            + isResizableParam + ") - start");
599:                }
600:
601:                this .isResizable = isResizableParam;
602:
603:                if (logger.isDebugEnabled()) {
604:                    logger.debug("setIsResizable(boolean) - end");
605:                }
606:            }
607:
608:            /**
609:             * <p>
610:             * Set this value to specify the application-specific path (beginning with a
611:             * '/') which the new window will show.
612:             * </p>
613:             *
614:             * @param pageParam
615:             *            the new value of page.
616:             */
617:            public void setPage(final String pageParam) {
618:                if (logger.isDebugEnabled()) {
619:                    logger.debug("setPage(String pageParam = " + pageParam
620:                            + ") - start");
621:                }
622:
623:                this .page = pageParam;
624:
625:                if (logger.isDebugEnabled()) {
626:                    logger.debug("setPage(String) - end");
627:                }
628:            }
629:
630:            /**
631:             * <p>
632:             * Set the page context used to calculate the window <i>URL </i>.
633:             * </p>
634:             *
635:             * @param pageContextParam
636:             *            new value of page context.
637:             */
638:            public void setPageContext(final PageContext pageContextParam) {
639:                if (logger.isDebugEnabled()) {
640:                    logger
641:                            .debug("setPageContext(PageContext pageContextParam = "
642:                                    + pageContextParam + ") - start");
643:                }
644:
645:                this .pageContext = pageContextParam;
646:
647:                if (logger.isDebugEnabled()) {
648:                    logger.debug("setPageContext(PageContext) - end");
649:                }
650:            }
651:
652:            /**
653:             * <p>
654:             * Specifies parameters for the page this window shows.
655:             * </p>
656:             *
657:             * @see TagUtils.getInstance().computeURL
658:             *
659:             * @param paramsParam
660:             *            the new value of the parameters.
661:             */
662:            public void setParams(final Map paramsParam) {
663:                if (logger.isDebugEnabled()) {
664:                    logger.debug("setParams(Map paramsParam = " + paramsParam
665:                            + ") - start");
666:                }
667:
668:                this .params = paramsParam;
669:
670:                if (logger.isDebugEnabled()) {
671:                    logger.debug("setParams(Map) - end");
672:                }
673:            }
674:
675:            /**
676:             * <p>
677:             * Specifies the name of a <code>java.util.Map</code> instance in the page
678:             * context which is used to specify parameters for the page this window
679:             * shows.
680:             * </p>
681:             *
682:             * @see TagUtils.getInstance().computeURL.
683:             * @param paramsNameParam
684:             *            the new value of paramsName.
685:             */
686:            public void setParamsName(final String paramsNameParam) {
687:                if (logger.isDebugEnabled()) {
688:                    logger.debug("setParamsName(String paramsNameParam = "
689:                            + paramsNameParam + ") - start");
690:                }
691:
692:                this .paramsName = paramsNameParam;
693:
694:                if (logger.isDebugEnabled()) {
695:                    logger.debug("setParamsName(String) - end");
696:                }
697:            }
698:
699:            /**
700:             * <p>
701:             * Set the width of the window. The default setting is <code>700</code>.
702:             * </p>
703:             *
704:             * @param widthParam
705:             *            the new value for the width of the window.
706:             */
707:            public void setWidth(final int widthParam) {
708:                if (logger.isDebugEnabled()) {
709:                    logger.debug("setWidth(int widthParam = " + widthParam
710:                            + ") - start");
711:                }
712:
713:                this .width = widthParam;
714:
715:                if (logger.isDebugEnabled()) {
716:                    logger.debug("setWidth(int) - end");
717:                }
718:            }
719:
720:            /**
721:             * <p>
722:             * Set a JavaScript object name for the new window.
723:             * </p>
724:             *
725:             * @param windowNameParam
726:             *            a JavaScript object name for the new window.
727:             */
728:            public void setWindowName(final String windowNameParam) {
729:                if (logger.isDebugEnabled()) {
730:                    logger.debug("setWindowName(String windowNameParam = "
731:                            + windowNameParam + ") - start");
732:                }
733:
734:                this .windowName = windowNameParam;
735:
736:                if (logger.isDebugEnabled()) {
737:                    logger.debug("setWindowName(String) - end");
738:                }
739:            }
740:
741:            /**
742:             * <p>
743:             * Create the JavaScript that makes the window and return it as a string.
744:             * </p>
745:             *
746:             * @return the JavaScript that makes the window.
747:             */
748:            public String toString() {
749:                if (logger.isDebugEnabled()) {
750:                    logger.debug("toString() - start");
751:                }
752:
753:                StringBuffer buffer = new StringBuffer();
754:                // if the window name was set, begin with that
755:                if (windowName != null) {
756:                    buffer.append("var ");
757:                    buffer.append(windowName);
758:                    buffer.append(" = ");
759:                }
760:                // we need a URL and a frameName
761:                if (page == null) {
762:                    String returnString = alertError("No page parameter was set.");
763:                    if (logger.isDebugEnabled()) {
764:                        logger.debug("toString() - end - return value = "
765:                                + returnString);
766:                    }
767:                    return returnString;
768:                }
769:                if (pageContext == null) {
770:                    String returnString = alertError("No pageContext parameter was set.");
771:                    if (logger.isDebugEnabled()) {
772:                        logger.debug("toString() - end - return value = "
773:                                + returnString);
774:                    }
775:                    return returnString;
776:                }
777:                // see if we were specified parameters
778:                if (paramsName != null) {
779:                    params = (Map) pageContext.findAttribute(paramsName);
780:                }
781:                try {
782:                    String uRL = TagUtils.getInstance().computeURL(pageContext,
783:                            null, null, page, null, null, params, null, false);
784:                    if (frameName == null) {
785:                        String returnString = alertError("No frameName parameter was set.");
786:                        if (logger.isDebugEnabled()) {
787:                            logger.debug("toString() - end - return value = "
788:                                    + returnString);
789:                        }
790:                        return returnString;
791:                    }
792:                    buffer.append("window.open(\"");
793:                    buffer.append(uRL);
794:                    buffer.append("\", \"");
795:                    buffer.append(frameName);
796:                    buffer.append("\", \"toolbar=");
797:                    if (hasToolBar) {
798:                        buffer.append("yes");
799:                    } else {
800:                        buffer.append("no");
801:                    }
802:                    buffer.append(",menubar=");
803:                    if (hasMenuBar) {
804:                        buffer.append("yes");
805:                    } else {
806:                        buffer.append("no");
807:                    }
808:                    buffer.append(",scrollbars=");
809:                    if (hasScrollBars) {
810:                        buffer.append("auto");
811:                    } else {
812:                        buffer.append("no");
813:                    }
814:                    buffer.append(",height=");
815:                    buffer.append(height);
816:                    buffer.append(",width=");
817:                    buffer.append(width);
818:                    buffer.append(",top=200");
819:                    buffer.append(",left=200");
820:                    buffer.append(",resizable=");
821:                    if (isResizable) {
822:                        buffer.append("yes");
823:                    } else {
824:                        buffer.append("no");
825:                    }
826:                    buffer.append("\");");
827:                    String returnString = buffer.toString();
828:                    if (logger.isDebugEnabled()) {
829:                        logger.debug("toString() - end - return value = "
830:                                + returnString);
831:                    }
832:                    return returnString;
833:                } catch (MalformedURLException e) {
834:                    logger.error("toString()", e);
835:
836:                    String returnString = alertError("Malformed URL: "
837:                            + e.getMessage());
838:                    if (logger.isDebugEnabled()) {
839:                        logger.debug("toString() - end - return value = "
840:                                + returnString);
841:                    }
842:                    return returnString;
843:                }
844:            }
845:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.