1 15 package org.apache.tapestry.contrib.link; 16 17 import org.apache.tapestry.IRequestCycle; 18 import org.apache.tapestry.engine.ILink; 19 import org.apache.tapestry.link.DefaultLinkRenderer; 20 21 27 public class PopupLinkRenderer extends DefaultLinkRenderer 28 { 29 30 private String _windowName; 31 32 private String _features; 33 34 public PopupLinkRenderer() 35 { 36 } 37 38 44 public PopupLinkRenderer(String windowName, String features) 45 { 46 _windowName = windowName; 47 _features = features; 48 } 49 50 53 protected String constructURL(ILink link, String anchor, IRequestCycle cycle) 54 { 55 String url = link.getURL(anchor, true); 56 return "javascript: w = window.open(" + normalizeString(url) + ", " + normalizeString(getWindowName()) + ", " + normalizeString(getFeatures()) + "); w.focus();"; 57 } 58 59 private String normalizeString(String str) 60 { 61 return str == null ? "''" : "'" + str + "'"; 62 } 63 64 public String getWindowName() 65 { 66 return _windowName; 67 } 68 69 public void setWindowName(String windowName) 70 { 71 _windowName = windowName; 72 } 73 74 public String getFeatures() 75 { 76 return _features; 77 } 78 79 public void setFeatures(String features) 80 { 81 _features = features; 82 } 83 } 84 | Popular Tags |