1 18 package org.apache.beehive.netui.tags.databinding.datagrid; 19 20 import javax.servlet.jsp.JspException ; 21 import javax.servlet.http.HttpServletRequest ; 22 23 import org.apache.beehive.netui.databinding.datagrid.api.rendering.CellModel; 24 import org.apache.beehive.netui.databinding.datagrid.runtime.model.cell.ImageCellModel; 25 import org.apache.beehive.netui.databinding.datagrid.runtime.rendering.cell.ImageCellDecorator; 26 import org.apache.beehive.netui.databinding.datagrid.runtime.util.JspUtil; 27 import org.apache.beehive.netui.tags.rendering.AbstractHtmlState; 28 import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender; 29 import org.apache.beehive.netui.tags.rendering.ImageTag; 30 import org.apache.beehive.netui.tags.html.HtmlConstants; 31 import org.apache.beehive.netui.tags.IHtmlEvents; 32 import org.apache.beehive.netui.tags.IHtmlCore; 33 import org.apache.beehive.netui.tags.IHtmlI18n; 34 35 71 public class ImageCell 72 extends AbstractHtmlTableCell 73 implements IHtmlCore, IHtmlEvents, IHtmlI18n { 74 75 private static final ImageCellDecorator DECORATOR = new ImageCellDecorator(); 76 private static final String IMAGE_FACET_NAME = "image"; 77 78 private ImageCellModel _imageCellModel = new ImageCellModel(); 79 private ImageTag.State _imageState = _imageCellModel.getImageState(); 80 81 85 public String getTagName() { 86 return "ImageCell"; 87 } 88 89 97 public void setOnClick(String onClick) { 98 _imageState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONCLICK, onClick); 99 } 100 101 109 public void setOnDblClick(String onDblClick) { 110 _imageState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONDBLCLICK, onDblClick); 111 } 112 113 121 public void setOnKeyDown(String onKeyDown) { 122 _imageState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONKEYDOWN, onKeyDown); 123 } 124 125 133 public void setOnKeyUp(String onKeyUp) { 134 _imageState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONKEYUP, onKeyUp); 135 } 136 137 145 public void setOnKeyPress(String onKeyPress) { 146 _imageState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONKEYPRESS, onKeyPress); 147 } 148 149 157 public void setOnMouseDown(String onMouseDown) { 158 _imageState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEDOWN, onMouseDown); 159 } 160 161 169 public void setOnMouseUp(String onMouseUp) { 170 _imageState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEUP, onMouseUp); 171 } 172 173 181 public void setOnMouseMove(String onMouseMove) { 182 _imageState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEMOVE, onMouseMove); 183 } 184 185 193 public void setOnMouseOut(String onMouseOut) { 194 _imageState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEOUT, onMouseOut); 195 } 196 197 205 public void setOnMouseOver(String onMouseOver) { 206 _imageState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEOVER, onMouseOver); 207 } 208 209 217 public void setStyle(String style) { 218 if("".equals(style)) return; 219 220 _imageState.style = style; 221 } 222 223 231 public void setStyleClass(String styleClass) { 232 if("".equals(styleClass)) return; 233 234 _imageState.styleClass = styleClass; 235 } 236 237 245 public void setTitle(String title) { 246 _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.TITLE, title); 247 } 248 249 257 public void setLang(String lang) 258 { 259 _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.LANG, lang); 260 } 261 262 269 public void setDir(String dir) 270 { 271 _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.DIR, dir); 272 } 273 274 281 public void setSrc(String src) { 282 _imageState.src = src; 283 } 284 285 293 public void setAlign(String align) { 294 _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.ALIGN, align); 295 } 296 297 305 public void setHspace(String hspace) { 306 _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.HSPACE, hspace); 307 } 308 309 316 public void setVspace(String vspace) { 317 _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.VSPACE, vspace); 318 } 319 320 327 public void setBorder(String border) { 328 _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.BORDER, border); 329 } 330 331 338 public void setHeight(String height) { 339 _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.HEIGHT, height); 340 } 341 342 349 public void setWidth(String width) { 350 _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.WIDTH, width); 351 } 352 353 361 public void setLongdesc(String longdesc) { 362 _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.LONGDESC, longdesc); 363 } 364 365 373 public void setAlt(String alt) { 374 _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.ALT, alt); 375 } 376 377 386 public void setTagId(String tagId) 387 throws JspException { 388 applyIndexedTagId(_imageState, tagId); 389 } 390 391 410 public void setAttribute(String name, String value, String facet) 411 throws JspException { 412 if(facet == null || facet.equals(IMAGE_FACET_NAME)) 413 super.addStateAttribute(_imageState, name, value); 414 else 415 super.setAttribute(name, value, facet); 416 } 417 418 424 protected void renderDataCellContents(AbstractRenderAppender appender, String jspFragmentOutput) { 425 426 if (_imageState.id != null) { 427 HttpServletRequest request = JspUtil.getRequest(getJspContext()); 428 String script = renderNameAndId(request, _imageState, null); 429 _imageCellModel.setJavascript(script); 430 } 431 432 DECORATOR.decorate(getJspContext(), appender, _imageCellModel); 433 } 434 435 441 protected CellModel internalGetCellModel() { 442 return _imageCellModel; 443 } 444 } 445 | Popular Tags |