1 64 65 package com.jcorporate.expresso.ext.struts.taglib.html; 66 67 73 74 import com.jcorporate.expresso.core.misc.StringUtil; 75 import org.apache.struts.taglib.html.LinkTag; 76 77 import javax.servlet.jsp.JspException ; 78 import javax.servlet.jsp.tagext.TagSupport ; 79 80 85 public class ExRemoteLayerTag extends LinkTag { 86 87 private static String STR_HREF_JS_LAYER = ""; 88 private static String STR_JS_LAYER = "%action%%id%('%type%');return false;"; 89 private static String SHOW_JS = "showLayer"; 90 private static String HIDE_JS = "hideLayer"; 91 private static String EXPAND = "EXPAND"; 92 private static String COLLAPSE = "COLLAPSE"; 93 94 private String node = EXPAND; 95 private String id = ""; 96 private String action = SHOW_JS; 97 98 99 104 public int doStartTag() throws JspException { 105 String href = STR_HREF_JS_LAYER; 106 String hrefClick = STR_JS_LAYER; 107 108 if (action.equalsIgnoreCase("SHOW")) { 109 this.action = SHOW_JS; 110 } else { 111 if (action.equalsIgnoreCase("HIDE")) { 112 this.action = HIDE_JS; 113 } else { 114 throw new JspException ("action must be 'Show' or 'Hide'"); 115 } 116 } 117 118 hrefClick += StringUtil.notNull(getOnclick()); 119 hrefClick = StringUtil.replaceString(hrefClick, "%id%", id); 120 hrefClick = StringUtil.replaceString(hrefClick, "%action%", action); 121 hrefClick = StringUtil.replaceString(hrefClick, "%type%", node); 122 super.setHref(href); 123 super.setOnclick(hrefClick); 124 Object tagParent = getParent(); 125 if (tagParent != null) { 126 if (action.equals(HIDE_JS)) { 127 if (tagParent.getClass().getName().equals(ExLayerInputTag.class.getName())) { 128 ExLayerInputTag layerParent = (ExLayerInputTag) tagParent; 129 layerParent.addLayerToHide(id); 130 } 131 } 132 } 133 return super.doStartTag(); 134 } 135 136 141 public String getId() { 142 return id; 143 } 144 145 150 public void setId(String id) { 151 this.id = id; 152 } 153 154 155 160 public String getAction() { 161 return action; 162 } 163 164 169 public void setAction(String action) { 170 this.action = action; 171 } 172 173 174 private TagSupport getAncestor(String className) 175 throws JspException { 176 Class klass = null; 177 178 try { 179 klass = Class.forName(className); 180 } catch (ClassNotFoundException ex) { 181 throw new JspException (ex.getMessage()); 182 } 183 184 return (TagSupport ) findAncestorWithClass(this, klass); 185 } 186 187 192 public String getNode() { 193 return node; 194 } 195 196 201 public void setNode(String node) throws JspException { 202 if (node.equalsIgnoreCase(EXPAND)) { 203 this.node = EXPAND; 204 } else { 205 if (node.equalsIgnoreCase(COLLAPSE)) { 206 this.node = COLLAPSE; 207 } else { 208 throw new JspException ("node must be 'collapse' or 'expand'"); 209 } 210 } 211 } 212 213 } 214 215 | Popular Tags |