1 37 package net.thauvin.google.taglibs; 38 39 import net.thauvin.google.TagUtility; 40 41 import javax.servlet.jsp.*; 42 43 44 52 public class Element extends StyleSupport 53 { 54 private SearchResult parentTag = null; 55 private String name = null; 56 57 62 public final void setName(String name) 63 { 64 this.name = name; 65 } 66 67 73 public int doEndTag() 74 throws JspException 75 { 76 if (TagUtility.isValidString(name, true)) 77 { 78 try 79 { 80 String property = ""; 81 82 int sep = name.indexOf('-'); 83 84 if (sep != -1) 85 { 86 String url = 87 parentTag.getElementProperty(name.substring(sep + 1)); 88 String body = 89 parentTag.getElementProperty(name.substring(0, sep)); 90 91 if (body.length() == 0) 92 { 93 body = url; 94 } 95 96 property = 97 TagUtility.buildRefLink(url, body, target, style, css); 98 } 99 else 100 { 101 property = parentTag.getElementProperty(name); 102 } 103 104 pageContext.getOut().write(property); 105 } 106 catch (Exception e) 107 { 108 throw TagUtility.outputError("result", e); 109 } 110 } 111 112 reset(); 114 115 return EVAL_PAGE; 116 } 117 118 124 public int doStartTag() 125 throws JspTagException 126 { 127 parentTag = 129 (SearchResult)findAncestorWithClass(this, SearchResult.class); 130 131 if (parentTag == null) 133 { 134 throw TagUtility.misplacedError("element", "searchResult"); 135 } 136 137 return (SKIP_BODY); 138 } 139 140 143 public void release() 144 { 145 super.release(); 146 147 parentTag = null; 149 } 150 151 154 protected void reset() 155 { 156 super.reset(); 157 } 158 } 159 | Popular Tags |