1 18 package org.apache.beehive.netui.tags.html; 19 20 import org.apache.beehive.netui.tags.ErrorHandling; 21 import org.apache.beehive.netui.tags.javascript.IScriptReporter; 22 import org.apache.beehive.netui.tags.rendering.AbstractHtmlState; 23 import org.apache.beehive.netui.tags.rendering.BodyTag; 24 import org.apache.beehive.netui.tags.rendering.TagRenderingBase; 25 import org.apache.beehive.netui.tags.rendering.WriteRenderAppender; 26 27 import javax.servlet.http.HttpServletRequest ; 28 import javax.servlet.jsp.JspException ; 29 30 36 public class Body extends HtmlBaseTag 37 { 38 private BodyTag.State _state = new BodyTag.State(); 39 private TagRenderingBase _br; 40 private WriteRenderAppender _writer; 41 private String _idScript; 42 43 46 public String getTagName() 47 { 48 return "Body"; 49 } 50 51 56 protected AbstractHtmlState getState() 57 { 58 return _state; 59 } 60 61 70 public void setOnLoad(String onload) 71 { 72 _state.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONLOAD, onload); 73 } 74 75 84 public void setOnUnload(String onunload) 85 { 86 _state.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONUNLOAD, onunload); 87 } 88 89 98 public void setBackground(String background) 99 { 100 _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, BACKGROUND, background); 101 } 102 103 112 public void setBgcolor(String bgcolor) 113 { 114 _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, BGCOLOR, bgcolor); 115 } 116 117 126 public void setText(String text) 127 { 128 _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, TEXT, text); 129 } 130 131 140 public void setLink(String link) 141 { 142 _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, LINK, link); 143 } 144 145 154 public void setVlink(String vlink) 155 { 156 _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, VLINK, vlink); 157 } 158 159 168 public void setAlink(String alink) 169 { 170 _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ALINK, alink); 171 } 172 173 177 public int doStartTag() throws JspException 178 { 179 if (_state.id != null) { 181 _idScript = renderNameAndId((HttpServletRequest ) pageContext.getRequest(), _state, null); 182 } 183 184 _writer = new WriteRenderAppender(pageContext); 186 _br = TagRenderingBase.Factory.getRendering(TagRenderingBase.BODY_TAG, pageContext.getRequest()); 187 _br.doStartTag(_writer, _state); 188 189 return EVAL_BODY_INCLUDE; 190 } 191 192 196 public int doEndTag() throws JspException 197 { 198 if (hasErrors()) { 200 reportErrors(); 201 } 202 203 IScriptReporter sr = getScriptReporter(); 205 if (sr != null) { 206 211 ErrorHandling.reportCollectedErrors(pageContext, this); 213 214 sr.writeScript(_writer); 216 217 if (sr instanceof Html) { 218 Html htmlSr = (Html) sr; 219 if (htmlSr.getIdScope() != null) { 220 htmlSr.endScope(_writer); 221 } 222 } 223 } 224 225 if (_idScript != null) 226 write(_idScript); 227 228 _br.doEndTag(_writer); 229 230 localRelease(); 232 return EVAL_PAGE; 233 } 234 235 public void localRelease() 236 { 237 super.localRelease(); 238 _state.clear(); 239 _br = null; 240 _writer = null; 241 } 242 } 243 | Popular Tags |