1 18 package net.sf.uitags.tag.search; 19 20 import javax.servlet.jsp.JspException ; 21 22 import net.sf.uitags.tag.AbstractUiTag; 23 import net.sf.uitags.tagutil.TaglibProperties; 24 import net.sf.uitags.tagutil.validation.RuntimeValidator; 25 import net.sf.uitags.util.StringUtils; 26 import net.sf.uitags.util.Template; 27 28 34 public class SearchTag extends AbstractUiTag { 35 36 40 43 private static final long serialVersionUID = 100L; 44 45 46 47 51 private static final String PROP_EVENT = "search.on"; 52 private static final String PROP_INIT = "search.searchInitially"; 53 54 55 56 60 63 private String injectTo; 64 67 private String injectToName; 68 71 private String eventName; 72 75 private String searchStrategy; 76 79 private String targetPopulator; 80 83 private String listener; 84 87 private Boolean searchInitially; 88 89 90 91 95 98 public SearchTag() { 99 super(); 100 } 101 102 103 104 108 113 public void setInjectTo(String val) { 114 this.injectTo = val; 115 } 116 117 122 public void setInjectToName(String val) { 123 this.injectToName = val; 124 } 125 126 131 public void setOn(String val) { 132 this.eventName = val; 133 } 134 135 140 public void setSearchStrategy(String val) { 141 this.searchStrategy = val; 142 } 143 144 149 public void setTargetPopulator(String val) { 150 this.targetPopulator = val; 151 } 152 153 158 public void setListener(String val) { 159 this.listener = val; 160 } 161 162 167 public void setSearchInitially(Boolean val) { 168 this.searchInitially = val; 169 } 170 171 172 173 177 184 public int doStartTag() throws JspException { 185 return EVAL_BODY_INCLUDE; 186 } 187 188 194 public int doEndTag() throws JspException { 195 RuntimeValidator.assertAttributeExclusive( 196 "injectTo", this.injectTo, "injectToName", this.injectToName); 197 RuntimeValidator.assertEitherSpecified( 198 "injectTo", this.injectTo, "injectToName", this.injectToName); 199 200 TaglibProperties props = TaglibProperties.getInstance(); 201 props.setRuntimeProperty(PROP_EVENT, this.eventName); 202 props.setRuntimeProperty(PROP_INIT, StringUtils.toStringOrNull(this.searchInitially)); 203 204 Template tpl = Template.forName(Template.SEARCH); 205 tpl.map("injectTo", this.injectTo); 206 tpl.map("injectToName", this.injectToName); 207 tpl.map("triggerEvent", props.get(PROP_EVENT)); 208 tpl.map("searchStrategy", this.searchStrategy); 209 tpl.map("targetPopulator", this.targetPopulator); 210 tpl.map("listener", this.listener); 211 tpl.map("searchInitially", Boolean.valueOf(props.get(PROP_INIT))); 212 println(tpl.evalToString()); 213 214 return EVAL_PAGE; 215 } 216 } 217 | Popular Tags |