1 25 26 package org.objectweb.jonas.webapp.taglib; 27 28 import java.net.MalformedURLException ; 29 import java.util.Map ; 30 31 import javax.servlet.jsp.JspException ; 32 import javax.servlet.jsp.tagext.BodyTagSupport ; 33 import javax.servlet.jsp.tagext.Tag ; 34 35 import org.apache.struts.taglib.TagUtils; 36 37 38 41 public class TabTag extends BodyTagSupport { 42 43 private String m_Body = null; 45 private String m_Url = null; 46 47 49 private boolean selected = false; 50 private String href = null; 51 private String forward = null; 52 private String forwardControl = null; 53 56 public String getHref() { 57 return href; 58 } 59 60 public void setHref(String href) { 61 this.href = href; 62 } 63 64 67 public boolean getSelected() { 68 return (this.selected); 69 } 70 71 public void setSelected(boolean selected) { 72 this.selected = selected; 73 } 74 75 78 public String getForward() { 79 return forward; 80 } 81 82 public void setForward(String forward) { 83 this.forward = forward; 84 } 85 86 89 public String getForwardControl() { 90 return forwardControl; 91 } 92 93 public void setForwardControl(String forwardControl) { 94 this.forwardControl = forwardControl; 95 } 96 97 100 protected String anchor = null; 101 102 public String getAnchor() { 103 return (this.anchor); 104 } 105 106 public void setAnchor(String anchor) { 107 this.anchor = anchor; 108 } 109 110 113 protected String linkName = null; 114 115 public String getLinkName() { 116 return (this.linkName); 117 } 118 119 public void setLinkName(String linkName) { 120 this.linkName = linkName; 121 } 122 123 126 protected String name = null; 127 128 public String getName() { 129 return (this.name); 130 } 131 132 public void setName(String name) { 133 this.name = name; 134 } 135 136 140 protected String page = null; 141 142 public String getPage() { 143 return (this.page); 144 } 145 146 public void setPage(String page) { 147 this.page = page; 148 } 149 150 153 protected String paramId = null; 154 155 public String getParamId() { 156 return (this.paramId); 157 } 158 159 public void setParamId(String paramId) { 160 this.paramId = paramId; 161 } 162 163 166 protected String paramName = null; 167 168 public String getParamName() { 169 return (this.paramName); 170 } 171 172 public void setParamName(String paramName) { 173 this.paramName = paramName; 174 } 175 176 179 protected String paramProperty = null; 180 181 public String getParamProperty() { 182 return (this.paramProperty); 183 } 184 185 public void setParamProperty(String paramProperty) { 186 this.paramProperty = paramProperty; 187 } 188 189 192 protected String paramScope = null; 193 194 public String getParamScope() { 195 return (this.paramScope); 196 } 197 198 public void setParamScope(String paramScope) { 199 this.paramScope = paramScope; 200 } 201 202 205 protected String property = null; 206 207 public String getProperty() { 208 return (this.property); 209 } 210 211 public void setProperty(String property) { 212 this.property = property; 213 } 214 215 218 protected String scope = null; 219 220 public String getScope() { 221 return (this.scope); 222 } 223 224 public void setScope(String scope) { 225 this.scope = scope; 226 } 227 228 231 protected String target = null; 232 233 public String getTarget() { 234 return (this.target); 235 } 236 237 public void setTarget(String target) { 238 this.target = target; 239 } 240 241 244 protected boolean transaction = false; 245 246 public boolean getTransaction() { 247 return (this.transaction); 248 } 249 250 public void setTransaction(boolean transaction) { 251 this.transaction = transaction; 252 } 253 254 256 public int doStartTag() 257 throws JspException { 258 m_Body = null; 260 261 return (EVAL_BODY_BUFFERED); 263 } 264 265 public int doAfterBody() 266 throws JspException { 267 String sBody = bodyContent.getString(); 268 if (sBody != null) { 269 sBody = sBody.trim(); 270 if (sBody.length() > 0) { 271 this.m_Body = sBody; 272 } 273 } 274 return (SKIP_BODY); 275 } 276 277 282 public int doEndTag() 283 throws JspException { 284 285 Tag parent = findAncestorWithClass(this, TabsTag.class); 287 if ((parent == null) || !(parent instanceof TabsTag)) { 288 throw new JspException ("Must be nested in a TabsTag instance"); 289 } 290 TabsTag oTabs = (TabsTag) parent; 291 292 TagUtils tagUtils = TagUtils.getInstance(); 294 Map oParams = tagUtils.computeParameters(pageContext, paramId, paramName, paramProperty 295 , paramScope, name, property, scope, transaction); 296 m_Url = null; 297 try { 298 m_Url = tagUtils.computeURL(pageContext, forward, href, page, null, null, oParams, anchor, false); 299 } catch (MalformedURLException e) { 300 } 302 if ((m_Url == null) && (forwardControl != null) && (oTabs.isUsingWhere() == true)) { 304 try { 305 TreeControlNode oNode = oTabs.getSelectedTreeControlNode(); 307 if (oNode != null) { 308 try { 309 String sForward = tagUtils.computeURL(pageContext, forwardControl, null, null, null, null, null, null, false); 310 int iPos = oNode.getAction().indexOf("?"); 311 m_Url = sForward + oNode.getAction().substring(iPos); 312 } catch (MalformedURLException e) { 313 } 315 } 316 } catch (Exception ex) { 317 } 319 } 320 if (m_Url == null) { 322 m_Url = new String (""); 323 } 324 if (m_Body == null) { 326 m_Body = new String (""); 327 } 328 oTabs.addTab(m_Body, m_Url, selected); 331 332 return (EVAL_PAGE); 333 } 334 335 338 public void release() { 339 this.m_Body = null; 340 this.href = null; 341 this.forward = null; 342 this.forwardControl = null; 343 } 344 } 345 | Popular Tags |