KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > libtags > WindowOpenTag2


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6 package com.raptus.owxv3.libtags;
7
8 import java.io.IOException JavaDoc;
9
10 import javax.servlet.jsp.*;
11 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
12
13 import com.raptus.owxv3.LoggingManager;
14
15 /**
16  *
17  * <hr>
18  * <table width="100%" border="0">
19  * <tr>
20  * <td width="24%"><b>Filename</b></td><td width="76%">WindowOpenTag2.java</td>
21  * </tr>
22  * <tr>
23  * <td width="24%"><b>Author</b></td><td width="76%">Guy Zürcher</td>
24  * </tr>
25  * <tr>
26  * <td width="24%"><b>Date</b></td><td width="76%">9th of July 2002</td>
27  * </tr>
28  * </table>
29  * <hr>
30  * <table width="100%" border="0">
31  * <tr>
32  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
33  * </tr>
34  * </table>
35  * <hr>
36  *
37  */

38 public class WindowOpenTag2 extends TagSupport JavaDoc {
39
40
41     // ------------------------------------------------------------- Properties
42

43     /**
44      * The url wich should be opened in the new window
45      */

46     private String JavaDoc url = null;
47
48     public String JavaDoc getUrl() { return (this.url); }
49     public void setUrl(String JavaDoc url) { this.url = url; }
50
51     /**
52      *The name of the window, this is optional
53      */

54     private String JavaDoc name = null;
55
56     public String JavaDoc getName() { return (this.name); }
57     public void setName(String JavaDoc name) { this.name = name; }
58
59     /**
60      *The width of the window
61      */

62     private int width;
63
64     public int getWidth() { return (this.width); }
65     public void setWidth(int w) { this.width = w; }
66
67     /**
68      *The height of the window
69      */

70     private int height;
71
72     public int getHeight() { return (this.height); }
73     public void setHeight(int h) { this.height = h; }
74
75     /**
76      * If the window has a toolbar
77      */

78     private boolean toolbar;
79
80     public boolean getToolbar() { return (this.toolbar); }
81     public void setToolbar(boolean t) { this.toolbar = t; }
82     
83     /**
84      * If the window has a location bar
85      */

86     private boolean location;
87
88     public boolean getLocation() { return (this.location); }
89     public void setLocation(boolean l) { this.location = l; }
90
91     /**
92      * If the window has a status bar
93      */

94     private boolean status;
95
96     public boolean getStatus() { return (this.status); }
97     public void setStatus(boolean s) { this.status = s; }
98
99     /**
100      * If the window has a menu bar
101      */

102     private boolean menu;
103
104     public boolean getMenu() { return (this.menu); }
105     public void setMenu(boolean m) { this.menu = m; }
106
107     /**
108      * If the window has a scroll bar
109      */

110     private boolean scroll;
111
112     public boolean getScroll() { return (this.scroll); }
113     public void setScroll(boolean s) { this.scroll = s; }
114     
115     /**
116      * If the window is resizeable
117      */

118     private boolean resizable;
119
120     public boolean getResizable() { return (this.resizable); }
121     public void setResizable(boolean r) { this.resizable = r; }
122
123     /**
124      * Link text if no JS
125      */

126     private String JavaDoc ltext = "";
127     
128     public String JavaDoc getLtext() { return (this.ltext); }
129     public void setLtext(String JavaDoc lt) { this.ltext = lt; }
130     
131     // --------------------------------------------------------- Public Methods
132

133
134     /**
135      * Process the start tag.
136      *
137      * NOTE: in the JavaScript disabled case, the link is rendered using the
138      * url, name as target and ltext as linktext.
139      *
140      * @exception JspException if a JSP exception has occurred
141      *
142      */

143     public int doStartTag() throws JspException
144     {
145         if(name == null)
146             name="wndname2";
147         
148         try
149         {
150             JspWriter out = pageContext.getOut();
151             out.println("<script language=\"javascript\">");
152             out.println("// <!--");
153             out.print("window.open(\\'");
154             out.print(url);
155             out.print("\\',\\'");
156             out.print(name);
157             out.print("\\',\\'width=");
158             out.print(width);
159             out.print(",height=");
160             out.print(height);
161             
162             if(toolbar) out.print(",toolbar=yes");
163             if(location) out.print(",location=yes");
164             if(status) out.print(",status=yes");
165             if(menu) out.print(",menubar=yes");
166             if(scroll) out.print(",scrollbars=yes");
167             if(resizable) out.print(",resizable=yes");
168             
169             out.print("\\')");
170             
171             out.println("// -->");
172             out.println("</script>");
173             out.println("<noscript>");
174
175             out.print("<a HREF=\"");
176             out.print(url);
177             out.print("\" target=\"");
178             out.print(name);
179             out.print("\">");
180             out.print(ltext);
181             out.print("</a>");
182             out.println("</noscript>");
183
184         }
185         catch(IOException JavaDoc e) {
186             LoggingManager.log("Somenthing really screwed up", this);
187         }
188
189     // Continue processing this page
190
return (SKIP_BODY);
191
192     }
193
194
195     /**
196      * Release any acquired resources.
197      */

198     public void release()
199     {
200         url = null;
201         name = null;
202         width = 0;
203         height = 0;
204         toolbar = false;
205         location = false;
206         status = false;
207         menu = false;
208         scroll = false;
209         resizable = false;
210         ltext = null;
211     }
212
213 }
214
215 // eof
216
Popular Tags