1 package fr.improve.struts.taglib.layout.field; 2 3 import javax.servlet.jsp.JspException ; 4 5 import fr.improve.struts.taglib.layout.LabelledTag; 6 import fr.improve.struts.taglib.layout.el.Expression; 7 import fr.improve.struts.taglib.layout.util.LayoutUtils; 8 import fr.improve.struts.taglib.layout.util.TagUtils; 9 10 16 public class OptionTag extends LabelledTag implements Choice { 17 20 protected String value; 21 22 25 protected String tooltip; 26 27 30 protected String choiceLabel; 31 32 35 protected String choiceTooltip; 36 37 public int doEndLayoutTag() throws JspException { 38 StringBuffer buffer = new StringBuffer (); 39 if (key!=null) choiceLabel = getLabel(); else choiceLabel = value; 40 choiceTooltip = LayoutUtils.getLabel(pageContext, bundle, tooltip, null, false); 41 ChoiceTag choiceTag = (ChoiceTag) findAncestorWithClass(this, ChoiceTag.class); 42 if (choiceTag==null) { 43 throw new JspException ("<layout:option> is not in a <layout:select> or <layout:radios> tag"); 44 } 45 choiceTag.addChoice(buffer,this); 46 TagUtils.write(pageContext, buffer.toString()); 47 return EVAL_PAGE; 48 } 49 public int doStartLayoutTag() { 50 return EVAL_BODY_INCLUDE; 51 } 52 public void release() { 53 super.release(); 54 value = null; 55 tooltip = null; 56 } 57 public void setValue(String value) { 58 this.value = value; 59 } 60 public String getValue() { 61 return value; 62 } 63 public String getTooltip() { 64 return tooltip; 65 } 66 public void setTooltip(String tooltip) { 67 this.tooltip = tooltip; 68 } 69 70 73 public String getChoiceLabel() { 74 return choiceLabel; 75 } 76 79 public String getChoiceTooltip() { 80 return choiceTooltip; 81 } 82 85 public String getChoiceValue() { 86 return Expression.evaluate(value, pageContext); 87 } 88 } 89 | Popular Tags |