KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.apache.struts.Globals;
14 import org.apache.struts.action.Action;
15 import org.apache.struts.util.RequestUtils;
16
17 import com.raptus.owxv3.LoggingManager;
18
19 /**
20  *
21  * <hr>
22  * <table width="100%" border="0">
23  * <tr>
24  * <td width="24%"><b>Filename</b></td><td width="76%">PopupConfirmTag.java</td>
25  * </tr>
26  * <tr>
27  * <td width="24%"><b>Author</b></td><td width="76%">Guy Zürcher (gzuercher@raptus.com)</td>
28  * </tr>
29  * <tr>
30  * <td width="24%"><b>Date</b></td><td width="76%">20th of August 2001</td>
31  * </tr>
32  * </table>
33  * <hr>
34  * <table width="100%" border="0">
35  * <tr>
36  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
37  * </tr>
38  * </table>
39  * <hr>
40  */

41 public class PopupConfirmTag extends TagSupport JavaDoc {
42
43
44     // ------------------------------------------------------------- Properties
45

46     /**
47      *
48      */

49     protected String JavaDoc okurl = null;
50
51     public String JavaDoc getOkurl() { return (this.okurl); }
52     public void setOkurl(String JavaDoc url) { this.okurl = url; }
53
54     /**
55      *
56      */

57     protected String JavaDoc cancelurl = null;
58
59     public String JavaDoc getCancelurl() { return (this.cancelurl); }
60     public void setCancelurl(String JavaDoc url) { this.cancelurl = url; }
61
62     /**
63      *
64      */

65     protected String JavaDoc displaytag = null;
66
67     public String JavaDoc getDisplaytag() { return (this.displaytag); }
68     public void setDisplaytag(String JavaDoc tag) { this.displaytag = tag; }
69
70     /**
71      *
72      */

73     protected String JavaDoc hreftext = null;
74
75     public String JavaDoc getHreftext() { return (this.hreftext); }
76     public void setHreftext(String JavaDoc text) { this.hreftext = text; }
77
78     /**
79      *
80      */

81     protected String JavaDoc statustext = null;
82
83     public String JavaDoc getStatustext() { return (this.statustext); }
84     public void setStatustext(String JavaDoc text) { this.statustext = text; }
85
86     /**
87      *
88      */

89     protected String JavaDoc confirmtext = null;
90
91     public String JavaDoc getConfirmtext() { return (this.confirmtext); }
92     public void setConfirmtext(String JavaDoc text) { this.confirmtext = text; }
93
94     /**
95      *
96      */

97     protected String JavaDoc target = null;
98
99     public String JavaDoc getTarget() { return (this.target); }
100     public void setTarget(String JavaDoc target) { this.target = target; }
101
102     /**
103      *
104      */

105     protected String JavaDoc resources = Action.MESSAGES_KEY;;
106
107     public String JavaDoc getResources() { return (this.resources); }
108     public void setResources(String JavaDoc res) { this.resources = res; }
109
110     // --------------------------------------------------------- Public Methods
111

112
113     /**
114      * Process the start tag.
115      *
116      * @exception JspException if a JSP exception has occurred
117      */

118     public int doStartTag() throws JspException
119     {
120         if(cancelurl != null && cancelurl.length() > 0)
121             cancelurl = "else { location=\\'" + cancelurl + "\\'; } ";
122         else
123             cancelurl = "";
124
125         if(resources != null)
126         {
127             if(confirmtext != null) confirmtext = RequestUtils.message(pageContext, resources, Globals.LOCALE_KEY, confirmtext);
128             if(hreftext != null) hreftext = RequestUtils.message(pageContext, resources, Globals.LOCALE_KEY, hreftext);
129             if(statustext != null) statustext = RequestUtils.message(pageContext, resources, Globals.LOCALE_KEY, statustext);
130         }
131
132         try
133         {
134             JspWriter out = pageContext.getOut();
135             out.println("<script language=\"javascript\">");
136             out.println("// <!--");
137             out.println(" document.write('<a HREF=\"javascript:if(confirm(\\'" + confirmtext + "\\')) { location=\\'" + okurl + "\\'; } " + cancelurl + "\" '); ");
138             out.println(" document.write('title=\"" + hreftext + "\" onmouseover=\"window.status=\\'" + statustext + "\\'; return true\" ');");
139             out.println(" document.write('" + (target != null ? target : "") + ">" + displaytag + "</a>');");
140             out.println("// -->");
141             out.println("</script>");
142             out.println("<noscript>");
143             out.println(" <a HREF=\"" + okurl + "\" title=\"" + hreftext + "\">" + displaytag + "</a>");
144             out.println("</noscript>");
145         }
146         catch(IOException JavaDoc e) {
147             LoggingManager.log("Somenthing really screwed up", this);
148         }
149
150     // Continue processing this page
151
return (SKIP_BODY);
152
153     }
154
155
156     /**
157      * Release any acquired resources.
158      */

159     public void release()
160     {
161         okurl = null;
162         cancelurl = null;
163         displaytag = null;
164         hreftext = null;
165         statustext = null;
166         confirmtext = null;
167         target = null;
168     }
169
170 }
171
172 // eof
173
Popular Tags