1 18 package org.apache.beehive.netui.tags.html; 19 20 import org.apache.beehive.netui.tags.HtmlUtils; 21 import org.apache.beehive.netui.tags.rendering.AbstractHtmlState; 22 import org.apache.beehive.netui.tags.rendering.LabelTag; 23 import org.apache.beehive.netui.tags.rendering.TagRenderingBase; 24 import org.apache.beehive.netui.tags.rendering.WriteRenderAppender; 25 import org.apache.beehive.netui.util.Bundle; 26 import org.apache.beehive.netui.util.logging.Logger; 27 28 import javax.servlet.ServletRequest ; 29 import javax.servlet.http.HttpServletRequest ; 30 import javax.servlet.jsp.JspException ; 31 32 36 public class Label extends LabelBase 37 implements IFormattable 38 { 39 private static final Logger logger = Logger.getInstance(Label.class); 40 41 private LabelTag.State _state = new LabelTag.State(); 42 43 46 public String getTagName() 47 { 48 return "Label"; 49 } 50 51 56 protected AbstractHtmlState getState() 57 { 58 return _state; 59 } 60 61 70 public void setFor(String forAttr) 71 { 72 _state.forAttr = forAttr; 73 } 74 75 79 public int doStartTag() throws JspException ![JavaDoc](../../../../../../../cmn/javadoc.gif) 80 { 81 return EVAL_BODY_BUFFERED; 82 } 83 84 85 89 public int doEndTag() throws JspException ![JavaDoc](../../../../../../../cmn/javadoc.gif) 90 { 91 boolean usingDefault = false; 92 boolean bypassEscape = false; 93 94 String scriptId = null; 95 ServletRequest req = pageContext.getRequest(); 96 Object labelObject = null; 97 98 String labelValue = null; 99 100 if (_value != null) 102 labelObject = _value; 103 else { 104 if (_defaultValue != null) { 105 labelObject = _defaultValue; 106 bypassEscape = HtmlUtils.containsEntity(_defaultValue.toString()); 107 } 108 else { 109 logger.warn(Bundle.getString("Tags_LabelExpressionNull", _value)); 110 labelObject = DEFAULT_NULL_TEXT; 111 } 112 usingDefault = true; 113 } 114 115 if (_state.id != null) { 118 scriptId = renderNameAndId((HttpServletRequest ) req, _state, null); 119 } 120 121 labelValue = (usingDefault && !_formatDefaultValue) ? 123 labelObject.toString() : formatText(labelObject); 124 125 if (hasErrors()) 126 return reportAndExit(EVAL_PAGE); 127 128 if (_state.forAttr != null) { 130 _state.forAttr = getIdForTagId(_state.forAttr); 131 132 } 133 134 WriteRenderAppender writer = new WriteRenderAppender(pageContext); 135 TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.LABEL_TAG, req); 136 br.doStartTag(writer, _state); 137 138 142 if (!bypassEscape) 143 filter(labelValue, writer, _escapeWhiteSpace); 144 else 145 write(labelValue); 146 br.doEndTag(writer); 147 148 if (scriptId != null) 149 write(scriptId); 150 151 localRelease(); 152 return EVAL_PAGE; 153 } 154 155 158 protected void localRelease() 159 { 160 super.localRelease(); 161 162 _state.clear(); 163 } 164 } 165 | Popular Tags |