1 5 6 package com.raptus.owxv3.libtags; 7 8 import java.io.IOException ; 9 10 import javax.servlet.jsp.*; 11 import javax.servlet.jsp.tagext.TagSupport ; 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 50 public class WindowOpenTag extends TagSupport { 51 52 53 55 58 private String url = null; 59 60 public String getUrl() { return (this.url); } 61 public void setUrl(String url) { this.url = url; } 62 63 64 67 private int width; 68 69 public int getWidth() { return (this.width); } 70 public void setWidth(int w) { this.width = w; } 71 72 73 76 private int height; 77 78 public int getHeight() { return (this.height); } 79 public void setHeight(int h) { this.height = h; } 80 81 84 private String displaytag = null; 85 86 public String getDisplaytag() { return (this.displaytag); } 87 public void setDisplaytag(String tag) { this.displaytag = tag; } 88 89 90 93 private String wname = null; 94 95 public String getWname() { return (this.wname); } 96 public void setWname(String wname) { this.wname = wname; } 97 98 99 102 private String statustext = null; 103 104 public String getStatustext() { return (this.statustext); } 105 public void setStatustext(String text) { this.statustext = text; } 106 107 108 111 private String resources = Action.MESSAGES_KEY;; 112 113 public String getResources() { return (this.resources); } 114 public void setResources(String res) { this.resources = res; } 115 116 117 119 120 125 public int doStartTag() throws JspException 126 { 127 if(wname==null) wname="wndname"; 128 129 if(resources==null) 130 { 131 statustext=""; 132 } 133 else 134 { 135 if(statustext!=null) statustext = RequestUtils.message(pageContext, resources, Globals.LOCALE_KEY, statustext); 136 else statustext=""; 137 } 138 139 140 141 try 142 { 143 JspWriter out = pageContext.getOut(); 144 out.println("<script language=\"javascript\">"); 145 out.println("// <!--"); 146 out.print("document.write('<a HREF=\"javascript:;\" onClick=\"window.open(\\'"); 147 out.print(url); 148 out.print("\\',\\'"); 149 out.print(wname); 150 out.print("\\',\\'width="); 151 out.print(width); 152 out.print(",height="); 153 out.print(height); 154 out.print("\\')\" onmouseover=\"window.status=\\'"); 155 String s=replace(statustext,"'","\\\\\\'"); 156 out.print(s); 157 out.print("\\'; return true\">"); 158 out.println("');"); 159 out.print("document.write('"); 160 s=replace(displaytag,"'","\\'"); 161 out.print(s); 162 out.println("</a>');"); 163 out.println("// -->"); 164 out.println("</script>"); 165 out.println("<noscript>"); 166 167 out.print("<a HREF=\""); 168 out.print(url); 169 out.print("\" target=\"_blank\">"); 170 out.print(displaytag); 171 out.print("</a>"); 172 out.println("</noscript>"); 173 174 } 175 catch(IOException e) { 176 LoggingManager.log("Somenthing really screwed up", this); 177 } 178 179 return (SKIP_BODY); 181 182 } 183 184 185 188 public void release() 189 { 190 url = null; 191 width = 0; 192 height = 0; 193 wname = null; 194 displaytag=null; 195 statustext=null; 196 } 197 198 199 208 private String replace(String line, String oldString,String newString) 209 { 210 if(line != null) 212 { 213 int i = 0; 214 if ((i = line.indexOf(oldString, i)) >= 0) 215 { 216 char [] line2 = line.toCharArray(); 217 char [] newString2 = newString.toCharArray(); 218 int oLength = oldString.length(); 219 StringBuffer buf = new StringBuffer (line2.length); 220 buf.append(line2, 0, i).append(newString2); 221 i += oLength; 222 int j = i; 223 while ((i = line.indexOf(oldString, i)) > 0) 224 { 225 buf.append(line2, j, i - j).append(newString2); 226 i += oLength; 227 j = i; 228 } 229 buf.append(line2, j, line2.length - j); 230 return buf.toString(); 231 } 232 } 233 234 return line; 235 } 236 237 } 238 239 | Popular Tags |