001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: * $Header:$
018: */
019: package org.apache.beehive.netui.tags.databinding.datagrid;
020:
021: import javax.servlet.jsp.JspException;
022: import javax.servlet.http.HttpServletRequest;
023:
024: import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender;
025: import org.apache.beehive.netui.tags.rendering.AbstractHtmlState;
026: import org.apache.beehive.netui.tags.rendering.ImageTag;
027: import org.apache.beehive.netui.tags.rendering.AnchorTag;
028: import org.apache.beehive.netui.tags.html.HtmlConstants;
029: import org.apache.beehive.netui.tags.html.IFormattable;
030: import org.apache.beehive.netui.tags.html.IUrlParams;
031: import org.apache.beehive.netui.databinding.datagrid.api.rendering.CellModel;
032: import org.apache.beehive.netui.databinding.datagrid.runtime.model.cell.ImageAnchorCellModel;
033: import org.apache.beehive.netui.databinding.datagrid.runtime.rendering.cell.ImageAnchorCellDecorator;
034: import org.apache.beehive.netui.databinding.datagrid.runtime.util.JspUtil;
035: import org.apache.beehive.netui.util.ParamHelper;
036:
037: /**
038: * <p>
039: * This tag is a data grid cell used to render an HTML image inside of an anchor. This tag should be used
040: * inside of a <netui-data:rows> tag when rendering a data set with the <netui-data:dataGrid> tag.
041: * The rendered output is structured as:
042: * <pre>
043: * <a ...><img .../></a>
044: * </pre>
045: * If the {@link #setHref(String)} attribute is set, the href will be rendered on the anchor. If the {@link #setAction(String)}
046: * attribute is set, it must reference an action that is valid in the context of the current Page Flow. Only
047: * one of these two attributes may be set. The image source to render on the image tag is specified using the
048: * {@link #setSrc(String)} attribute.
049: * </p>
050: * <p>
051: * The set of JSP implicit objects available to the body include:
052: * <ul>
053: * <li><code>dataGridModel</code> -- the {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.DataGridTagModel}
054: * for the cell's containing data grid.</li>
055: * <li><code>container</code> -- the {@link org.apache.beehive.netui.script.common.IDataAccessProvider} instance
056: * that exposes the current data item and the current item's index</li>
057: * </ul>
058: * </p>
059: *
060: * @jsptagref.tagdescription
061: * <p>
062: * This tag is a data grid cell used to render an HTML image inside of an anchor. This tag should be used
063: * inside of a <netui-data:rows> tag when rendering a data set with the <netui-data:dataGrid> tag.
064: * The rendered output is structured as:
065: * <pre>
066: * <a ...><img .../></a>
067: * </pre>
068: * If the {@link #setHref(String)} attribute is set, the href will be rendered on the anchor. If the {@link #setAction(String)}
069: * attribute is set, it must reference an action that is valid in the context of the current Page Flow. Only
070: * one of these two attributes may be set. The image source to render on the image tag is specified using the
071: * {@link #setSrc(String)} attribute.
072: * </p>
073: * <p>
074: * The set of JSP implicit objects available to the body include:
075: * <ul>
076: * <li><code>dataGridModel</code> -- the {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.DataGridTagModel}
077: * for the cell's containing data grid.</li>
078: * <li><code>container</code> -- the {@link org.apache.beehive.netui.script.common.IDataAccessProvider} instance
079: * that exposes the current data item and the current item's index</li>
080: * </ul>
081: * </p>
082: *
083: * @netui:tag name="imageAnchorCell" body-content="scriptless"
084: * description="Renders an HTML table cell in a data grid that contains an HTML image inside of an anchor."
085: */
086: public class ImageAnchorCell extends AbstractHtmlTableCell implements
087: IFormattable, IUrlParams {
088:
089: /*
090: todo: support rolloverImage on the <img> tags
091: */
092:
093: private static final ImageAnchorCellDecorator DECORATOR = new ImageAnchorCellDecorator();
094: private static final String IMAGE_FACET_NAME = "image";
095: private static final String ANCHOR_FACET_NAME = "anchor";
096:
097: private ImageAnchorCellModel _imageAnchorCellModel = new ImageAnchorCellModel();
098: private AnchorTag.State _anchorState = _imageAnchorCellModel
099: .getAnchorState();
100: private ImageTag.State _imageState = _imageAnchorCellModel
101: .getImageState();
102:
103: /**
104: * The name of this tag; this value is used for error reporting.
105: * @return the String name of this tag
106: */
107: public String getTagName() {
108: return "ImageAnchorCell";
109: }
110:
111: /**
112: * Sets the onClick JavaScript for the HTML anchor tag.
113: *
114: * @param onClick the onClick event.
115: * @jsptagref.attributedescription The onClick JavaScript for the HTML anchor tag.
116: * @jsptagref.attributesyntaxvalue <i>string_onClick</i>
117: * @netui:attribute required="false" rtexprvalue="true" description="The onClick JavaScript for the HTML anchor tag."
118: */
119: public void setOnClick(String onClick) {
120: _anchorState.registerAttribute(
121: AbstractHtmlState.ATTR_JAVASCRIPT,
122: HtmlConstants.ONCLICK, onClick);
123: }
124:
125: /**
126: * Sets the onDblClick JavaScript for the HTML anchor tag.
127: *
128: * @param onDblClick the onDblClick event.
129: * @jsptagref.attributedescription The onDblClick JavaScript for the HTML anchor tag.
130: * @jsptagref.attributesyntaxvalue <i>string_onDblClick</i>
131: * @netui:attribute required="false" rtexprvalue="true" description="The onDblClick JavaScript for the HTML anchor tag."
132: */
133: public void setOnDblClick(String onDblClick) {
134: _anchorState.registerAttribute(
135: AbstractHtmlState.ATTR_JAVASCRIPT,
136: HtmlConstants.ONDBLCLICK, onDblClick);
137: }
138:
139: /**
140: * Sets the onKeyDown JavaScript for the HTML anchor tag.
141: *
142: * @param onKeyDown the onKeyDown event.
143: * @jsptagref.attributedescription The onKeyDown JavaScript for the HTML anchor tag.
144: * @jsptagref.attributesyntaxvalue <i>string_onKeyDown</i>
145: * @netui:attribute required="false" rtexprvalue="true" description="The onKeyDown JavaScript for the HTML anchor tag."
146: */
147: public void setOnKeyDown(String onKeyDown) {
148: _anchorState.registerAttribute(
149: AbstractHtmlState.ATTR_JAVASCRIPT,
150: HtmlConstants.ONKEYDOWN, onKeyDown);
151: }
152:
153: /**
154: * Sets the onKeyUp JavaScript for the HTML anchor tag.
155: *
156: * @param onKeyUp the onKeyUp event.
157: * @jsptagref.attributedescription The onKeyUp JavaScript for the HTML anchor tag.
158: * @jsptagref.attributesyntaxvalue <i>string_onKeyUp</i>
159: * @netui:attribute required="false" rtexprvalue="true" description="The onKeyUp JavaScript for the HTML anchor tag."
160: */
161: public void setOnKeyUp(String onKeyUp) {
162: _anchorState.registerAttribute(
163: AbstractHtmlState.ATTR_JAVASCRIPT,
164: HtmlConstants.ONKEYUP, onKeyUp);
165: }
166:
167: /**
168: * Sets the onKeyPress JavaScript for the HTML anchor tag.
169: *
170: * @param onKeyPress the onKeyPress event.
171: * @jsptagref.attributedescription The onKeyPress JavaScript for the HTML anchor tag.
172: * @jsptagref.attributesyntaxvalue <i>string_onKeyPress</i>
173: * @netui:attribute required="false" rtexprvalue="true" description="The onKeyPress JavaScript for the HTML anchor tag."
174: */
175: public void setOnKeyPress(String onKeyPress) {
176: _anchorState.registerAttribute(
177: AbstractHtmlState.ATTR_JAVASCRIPT,
178: HtmlConstants.ONKEYPRESS, onKeyPress);
179: }
180:
181: /**
182: * Sets the onMouseDown JavaScript for the HTML anchor tag.
183: *
184: * @param onMouseDown the onMouseDown event.
185: * @jsptagref.attributedescription The onMouseDown JavaScript for the HTML anchor tag.
186: * @jsptagref.attributesyntaxvalue <i>string_onMouseDown</i>
187: * @netui:attribute required="false" rtexprvalue="true" description="The onMouseDown JavaScript for the HTML anchor tag."
188: */
189: public void setOnMouseDown(String onMouseDown) {
190: _anchorState.registerAttribute(
191: AbstractHtmlState.ATTR_JAVASCRIPT,
192: HtmlConstants.ONMOUSEDOWN, onMouseDown);
193: }
194:
195: /**
196: * Sets the onMouseUp JavaScript for the HTML anchor tag.
197: *
198: * @param onMouseUp the onMouseUp event.
199: * @jsptagref.attributedescription The onMouseUp JavaScript for the HTML anchor tag.
200: * @jsptagref.attributesyntaxvalue <i>string_onMouseUp</i>
201: * @netui:attribute required="false" rtexprvalue="true" description="The onMouseUp JavaScript for the HTML anchor tag."
202: */
203: public void setOnMouseUp(String onMouseUp) {
204: _anchorState.registerAttribute(
205: AbstractHtmlState.ATTR_JAVASCRIPT,
206: HtmlConstants.ONMOUSEUP, onMouseUp);
207: }
208:
209: /**
210: * Sets the onMouseMove JavaScript for the HTML anchor tag.
211: *
212: * @param onMouseMove the onMouseMove event.
213: * @jsptagref.attributedescription The onMouseMove JavaScript for the HTML anchor tag.
214: * @jsptagref.attributesyntaxvalue <i>string_onMouseMove</i>
215: * @netui:attribute required="false" rtexprvalue="true" description="The onMouseMove JavaScript for the HTML anchor tag."
216: */
217: public void setOnMouseMove(String onMouseMove) {
218: _anchorState.registerAttribute(
219: AbstractHtmlState.ATTR_JAVASCRIPT,
220: HtmlConstants.ONMOUSEMOVE, onMouseMove);
221: }
222:
223: /**
224: * Sets the onMouseOut JavaScript for the HTML anchor tag.
225: *
226: * @param onMouseOut the onMouseOut event.
227: * @jsptagref.attributedescription The onMouseOut JavaScript for the HTML anchor tag.
228: * @jsptagref.attributesyntaxvalue <i>string_onMouseOut</i>
229: * @netui:attribute required="false" rtexprvalue="true" description="The onMouseOut JavaScript for the HTML anchor tag."
230: */
231: public void setOnMouseOut(String onMouseOut) {
232: _anchorState.registerAttribute(
233: AbstractHtmlState.ATTR_JAVASCRIPT,
234: HtmlConstants.ONMOUSEOUT, onMouseOut);
235: }
236:
237: /**
238: * Sets the onMouseOver JavaScript for the HTML anchor tag.
239: *
240: * @param onMouseOver the onMouseOver event.
241: * @jsptagref.attributedescription The onMouseOver JavaScript for the HTML anchor tag.
242: * @jsptagref.attributesyntaxvalue <i>string_onMouseOver</i>
243: * @netui:attribute required="false" rtexprvalue="true" description="The onMouseOver JavaScript for the HTML anchor tag."
244: */
245: public void setOnMouseOver(String onMouseOver) {
246: _anchorState.registerAttribute(
247: AbstractHtmlState.ATTR_JAVASCRIPT,
248: HtmlConstants.ONMOUSEOVER, onMouseOver);
249: }
250:
251: /**
252: * Sets the style of the rendered HTML anchor tag.
253: *
254: * @param style the html style.
255: * @jsptagref.attributedescription The style for the HTML anchor tag.
256: * @jsptagref.attributesyntaxvalue <i>string_style</i>
257: * @netui:attribute required="false" rtexprvalue="true" description="The style."
258: */
259: public void setStyle(String style) {
260: if ("".equals(style))
261: return;
262:
263: _anchorState.style = style;
264: }
265:
266: /**
267: * Sets the style class of the rendered HTML anchor tag.
268: *
269: * @param styleClass the style class.
270: * @jsptagref.attributedescription The style class for the HTML anchor tag.
271: * @jsptagref.attributesyntaxvalue <i>string_style_class</i>
272: * @netui:attribute required="false" rtexprvalue="true" description="The style class for the HTML anchor tag."
273: */
274: public void setStyleClass(String styleClass) {
275: if ("".equals(styleClass))
276: return;
277:
278: _anchorState.styleClass = styleClass;
279: }
280:
281: /**
282: * Sets the value of the title attribute for the HTML anchor tag.
283: *
284: * @param title the title
285: * @jsptagref.attributedescription The title for the HTML anchor tag.
286: * @jsptagref.attributesyntaxvalue <i>string_title</i>
287: * @netui:attribute required="false" rtexprvalue="true" description="The title for the HTML anchor tag."
288: */
289: public void setTitle(String title) {
290: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
291: HtmlConstants.TITLE, title);
292: }
293:
294: /* ---------------------------------------------------------
295:
296: Anchor specifc attributes
297:
298: --------------------------------------------------------- */
299:
300: /**
301: * Sets <code>charset</code> attribute for the HTML anchor tag
302: *
303: * @param charSet the charset
304: * @jsptagref.attributedescription The character set for the HTML anchor tag.
305: * @jsptagref.attributesyntaxvalue <i>string_charset</i>
306: * @netui:attribute required="false" rtexprvalue="true"
307: * description="The character set for the HTML anchor tag."
308: */
309: public void setCharSet(String charSet) {
310: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
311: HtmlConstants.CHARSET, charSet);
312: }
313:
314: /**
315: * Sets <code>type</code> attribute for the HTML anchor tag.
316: *
317: * @param type the type
318: * @jsptagref.attributedescription The type attribute for the HTML anchor tag.
319: * @jsptagref.attributesyntaxvalue <i>string_type</i>
320: * @netui:attribute required="false" rtexprvalue="true"
321: * description="The type attribute for the HTML anchor tag."
322: */
323: public void setType(String type) {
324: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
325: HtmlConstants.TYPE, type);
326: }
327:
328: /**
329: * Sets <code>hreflang</code> attribute for the HTML anchor tag.
330: *
331: * @param hreflang the hreflang.
332: * @jsptagref.attributedescription The hreflang attribute for the HTML anchor tag.
333: * @jsptagref.attributesyntaxvalue <i>string_hreflang</i>
334: * @netui:attribute required="false" rtexprvalue="true"
335: * description="The hreflang attribute for the HTML anchor tag."
336: */
337: public void setHrefLang(String hreflang) {
338: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
339: HtmlConstants.HREFLANG, hreflang);
340: }
341:
342: /**
343: * Sets <code>rel</code> attribute for the HTML anchor tag.
344: *
345: * @param rel the rel attribute
346: * @jsptagref.attributedescription The rel attribute for the HTML anchor tag.
347: * @jsptagref.attributesyntaxvalue <i>string_rel</i>
348: * @netui:attribute required="false" rtexprvalue="true"
349: * description="The rel attribute for the HTML anchor tag."
350: */
351: public void setRel(String rel) {
352: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
353: HtmlConstants.REL, rel);
354: }
355:
356: /**
357: * Sets <code>rev</code> attribute for the HTML anchor tag.
358: *
359: * @param rev the rev attribute.
360: * @jsptagref.attributedescription The rev attribute for the HTML anchor tag.
361: * @jsptagref.attributesyntaxvalue <i>string_rev</i>
362: * @netui:attribute required="false" rtexprvalue="true"
363: * description="The rev attribute for the HTML anchor tag."
364: */
365: public void setRev(String rev) {
366: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
367: HtmlConstants.REV, rev);
368: }
369:
370: /**
371: * Sets the window target for the HTML anchor tag.
372: *
373: * @param target the window target
374: * @jsptagref.attributedescription The window target for the HTML anchor tag.
375: * @jsptagref.attributesyntaxvalue <i>string_action</i>
376: * @netui:attribute required="false" rtexprvalue="true"
377: * description="The window target for the HTML anchor tag."
378: */
379: public void setTarget(String target) {
380: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
381: HtmlConstants.TARGET, target);
382: }
383:
384: /**
385: * Sets the href of the HTML anchor tag. This attribute will accept the empty String as a legal value.
386: *
387: * @param href the hyperlink URI for the anchor.
388: * @jsptagref.attributedescription The HREF for the HTML anchor tag.
389: * @jsptagref.attributesyntaxvalue <i>string_href</i>
390: * @netui:attribute required="false" rtexprvalue="true" reftype="url"
391: * description="The HREF for the HTML anchor tag."
392: */
393: public void setHref(String href) {
394: _imageAnchorCellModel.setHref(href);
395: }
396:
397: /**
398: * Set the target "scope" for the anchor's action. Multiple active page flows may exist concurrently within named
399: * scopes. This attribute selects which named scope to use. If omitted, the default scope is assumed.
400: *
401: * @param targetScope the name of the target scope in which the associated action's page flow resides.
402: * @jsptagref.attributedescription The target scope in which the associated action's page flow resides.
403: * @jsptagref.attributesyntaxvalue <i>string_targetScope</i>
404: * @netui:attribute required="false" rtexprvalue="true"
405: * description="The target scope in which the associated action's page flow resides"
406: */
407: public void setTargetScope(String targetScope) {
408: _imageAnchorCellModel.setScopeId(targetScope);
409: }
410:
411: /**
412: * Set the name of the action for the HTML anchor tag. This action name must be valid given the
413: * current Page Flow.
414: *
415: * @param action the name of the action to set for the anchor tag.
416: * @jsptagref.attributedescription The action method to invoke. The action method must valid given the
417: * ccurrent Page Flow.
418: * @jsptagref.attributesyntaxvalue <i>string_action</i>
419: * @netui:attribute required="false" rtexprvalue="true"
420: * description="The action method to invoke. The action method must be in the Controller file of the Page Flow directory."
421: */
422: public void setAction(String action) throws JspException {
423: _imageAnchorCellModel.setAction(setRequiredValueAttribute(
424: action, "action"));
425: }
426:
427: /* ---------------------------------------------------------
428:
429: Image specifc attributes
430:
431: --------------------------------------------------------- */
432:
433: /**
434: * Sets the alignment attribute for the HTML image tag.
435: *
436: * @param align the image alignment.
437: * @jsptagref.attributedescription The alignment attribute for the HTML image tag.
438: * @jsptagref.attributesyntaxvalue <i>string_align</i>
439: * @netui:attribute required="false" rtexprvalue="true"
440: * description="The alignment for the HTML image tag."
441: */
442: public void setAlign(String align) {
443: _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
444: HtmlConstants.ALIGN, align);
445: }
446:
447: /**
448: * Sets the alt text attribute for the HTML image tag.
449: *
450: * @param alt the alt attribute.
451: * @jsptagref.attributedescription The alternative text of the HTML image tag.
452: * @jsptagref.attributesyntaxvalue <i>string_alt</i>
453: * @netui:attribute required="false" rtexprvalue="true"
454: * description="The alternative text of the HTML image tag."
455: */
456: public void setAlt(String alt) {
457: _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
458: HtmlConstants.ALT, alt);
459: }
460:
461: /**
462: * Sets the longdesc attribute for the HTML image tag.
463: *
464: * @param longdesc the longdesc attribute
465: * @jsptagref.attributedescription The longdesc attribute for the HTML image tag.
466: * @jsptagref.attributesyntaxvalue <i>string_alt</i>
467: * @netui:attribute required="false" rtexprvalue="true"
468: * description="the longdesc for the HTML image tag."
469: */
470: public void setLongdesc(String longdesc) {
471: _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
472: HtmlConstants.LONGDESC, longdesc);
473: }
474:
475: /**
476: * Sets the border size attribute for the HTML image tag.
477: *
478: * @param border the border size.
479: * @jsptagref.attributedescription The border size attribute for the HTML image tag.
480: * @jsptagref.attributesyntaxvalue <i>integer_pixelBorder</i>
481: * @netui:attribute required="false" rtexprvalue="true"
482: * description="The border size attribute for the HTML image tag."
483: */
484: public void setBorder(String border) {
485: _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
486: HtmlConstants.BORDER, border);
487: }
488:
489: /**
490: * Sets the image height attribute for the HTML image tag.
491: *
492: * @param height the height.
493: * @jsptagref.attributedescription The image height attribute for the HTML image tag.
494: * @jsptagref.attributesyntaxvalue <i>integer_height</i>
495: * @netui:attribute required="false" rtexprvalue="true"
496: * description="The image height attribute for the HTML image tag."
497: */
498: public void setHeight(String height) {
499: _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
500: HtmlConstants.HEIGHT, height);
501: }
502:
503: /**
504: * Sets the the horizontal spacing attribute for the HTML image tag.
505: *
506: * @param hspace the horizontal spacing.
507: * @jsptagref.attributedescription The horizontal spacing for the HTML image tag.
508: * @jsptagref.attributesyntaxvalue <i>integer_hspace</i>
509: * @netui:attribute required="false" rtexprvalue="true"
510: * description="The horizontal spacing for the HTML image tag."
511: */
512: public void setHspace(String hspace) {
513: _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
514: HtmlConstants.HSPACE, hspace);
515: }
516:
517: /**
518: * Sets the server-side image map declaration for the HTML image tag.
519: *
520: * @param ismap the image map declaration.
521: * @jsptagref.attributedescription The server-side map declaration for the HTML image tag.
522: * @jsptagref.attributesyntaxvalue <i>string_isMap</i>
523: * @netui:attribute required="false" rtexprvalue="true"
524: * description="The server-side map declaration for the HTML image tag."
525: */
526: public void setIsmap(String ismap) {
527: _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
528: HtmlConstants.ISMAP, ismap);
529: }
530:
531: /**
532: * Sets the image source URI for the HTML image tag.
533: *
534: * @param src the image source URI.
535: * @jsptagref.attributedescription The image source URI for the HTML image tag.
536: * @jsptagref.attributesyntaxvalue <i>string_src</i>
537: * @netui:attribute required="false" rtexprvalue="true"
538: * description="The image source URI for the HTML image tag" reftype="img-url"
539: */
540: public void setSrc(String src) throws JspException {
541: _imageState.src = src;
542: }
543:
544: /**
545: * Sets the client-side image map declaration for the HTML iage tag.
546: *
547: * @param usemap the map declaration.
548: * @jsptagref.attributedescription The client-side image map declaration for the HTML image tag.
549: * @jsptagref.attributesyntaxvalue <i>string_useMap</i>
550: * @netui:attribute required="false" rtexprvalue="true"
551: * description="The client-side image map declaration for the HTML image tag."
552: */
553: public void setUsemap(String usemap) {
554: _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
555: HtmlConstants.USEMAP, usemap);
556: }
557:
558: /**
559: * Sets the vertical spacing around the HTML image tag.
560: *
561: * @param vspace the vertical spacing.
562: * @jsptagref.attributedescription The vertical spacing around the HTML image tag.
563: * @jsptagref.attributesyntaxvalue <i>string_vspace</i>
564: * @netui:attribute required="false" rtexprvalue="true"
565: * description="The vertical spacing around the HTML image tag."
566: */
567: public void setVspace(String vspace) {
568: _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
569: HtmlConstants.VSPACE, vspace);
570: }
571:
572: /**
573: * Set the <img> style for the contained image. When the tag library is
574: * running in legacy mode, this will override the <code>style</code> attribute if that is
575: * set. If this is not set, and <code>style</code> is set, then it will be applied to
576: * the image.
577: *
578: * @param imageStyle the image style
579: * @jsptagref.attributedescription The style for the HTML image tag.
580: * @jsptagref.attributesyntaxvalue <i>string_style</i>
581: * @netui:attribute required="false" rtexprvalue="true"
582: * description="Set the style for the HTML image tag."
583: */
584: public void setImageStyle(String imageStyle) {
585: _imageState.style = imageStyle;
586: }
587:
588: /**
589: * Set the label style class for each contained Image. When the tag library is
590: * running in legacy mode, this will override the <code>styleClass</code> attribute if that is
591: * set. If this is not set, and <code>styleClass</code> is set, then it will be applied to
592: * the image.
593: *
594: * @param imageClass the image class
595: * @jsptagref.attributedescription The style class for the HTML image tag.
596: * @jsptagref.attributesyntaxvalue <i>string_style</i>
597: * @netui:attribute required="false" rtexprvalue="true"
598: * description="Set the style class for each contained image."
599: */
600: public void setImageStyleClass(String imageClass) {
601: _imageState.styleClass = imageClass;
602: }
603:
604: /**
605: * Sets the width attribute for the HTML image tag.
606: *
607: * @param width the image width.
608: * @jsptagref.attributedescription The width for the HTML image tag.
609: * @jsptagref.attributesyntaxvalue <i>integer_pixelWidth</i>
610: * @netui:attribute required="false" rtexprvalue="true"
611: * description="The width attribute for the HTML image tag."
612: */
613: public void setWidth(String width) {
614: _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
615: HtmlConstants.WIDTH, width);
616: }
617:
618: /**
619: * Set the name of the tagId for the HTML image tag.
620: *
621: * @param tagId the the name of the tagId for the image.
622: * @jsptagref.attributedescription The tagId for the HTML image tag.
623: * @jsptagref.attributesyntaxvalue <i>string_tagId</i>
624: * @netui:attribute required="false" rtexprvalue="true"
625: * description="String value. Sets the id (or name) attribute of the rendered HTML tag. "
626: */
627: public void setTagId(String tagId) throws JspException {
628: applyIndexedTagId(_imageState, tagId);
629: }
630:
631: /**
632: * Set the name of the tagId for the HTML image tag..
633: *
634: * @param tagId the the name of the tagId for the image.
635: * @jsptagref.attributedescription The tagId for the HTML image tag.
636: * @jsptagref.attributesyntaxvalue <i>string_tagId</i>
637: * @netui:attribute required="false" rtexprvalue="true"
638: * description="String value. Sets the id (or name) attribute of the rendered HTML tag. "
639: */
640: public void setAnchorTagId(String tagId) throws JspException {
641: applyIndexedTagId(_anchorState, tagId);
642: }
643:
644: /**
645: * <p>
646: * Implementation of the {@link org.apache.beehive.netui.tags.IAttributeConsumer} interface. This
647: * allows users of this tag to extend the attribute set that is rendered by the HTML image or
648: * anchor tags. This method accepts the following facets:
649: * <table>
650: * <tr><td>Facet Name</td><td>Operation</td></tr>
651: * <tr><td><code>anchor</code></td><td>Adds an attribute with the provided <code>name</code> and <code>value</code> to the
652: * attributes rendered on the <a> tag.</td></tr>
653: * <tr><td><code>image</code></td><td>Adds an attribute with the provided <code>name</code> and <code>value</code> to the
654: * attributes rendered on the <img> tag.</td></tr>
655: * </table>
656: * This tag defaults to the setting attributes on the anchor when the facet name is unset.
657: * </p>
658: * @param name the name of the attribute
659: * @param value the value of the attribute
660: * @param facet the facet for the attribute
661: * @throws JspException thrown when the facet is not recognized
662: */
663: public void setAttribute(String name, String value, String facet)
664: throws JspException {
665: if (facet == null || facet.equals(ANCHOR_FACET_NAME))
666: super .addStateAttribute(_anchorState, name, value);
667: else if (facet.equals(IMAGE_FACET_NAME))
668: super .addStateAttribute(_imageState, name, value);
669: else
670: super .setAttribute(name, value, facet);
671: }
672:
673: /**
674: * <p>
675: * Implementation of the {@link IUrlParams} interface. This allows this tag to accept <netui:parameter>
676: * and <netui:parameterMap> in order to add URL parameters onto the rendered anchor. For example:
677: * <pre>
678: * <netui-data:imageAnchorCell href="foo.jsp" src="foo.png">
679: * <netui:parameter name="paramKey" value="paramValue"/>
680: * </netui-data:anchorCell>
681: * </pre>
682: * will render an HTML image anchor as:
683: * <pre>
684: * <a href="foo.jsp?paramKey=paramValue><img src="foo.png"/></a>
685: * </pre>
686: * </p>
687: * @param name the name of the parameter
688: * @param value the value of the parameter
689: * @param facet the facet for the parameter
690: * @throws JspException thrown when the facet is unsupported
691: */
692: public void addParameter(String name, Object value, String facet)
693: throws JspException {
694: ParamHelper.addParam(_imageAnchorCellModel.getParams(), name,
695: value);
696: }
697:
698: /**
699: * Render the contents of the HTML anchor and image. This method calls to an
700: * {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.CellDecorator} associated with this tag.
701: * The result of renderingi is appended to the <code>appender</code>
702: * @param appender the {@link AbstractRenderAppender} to which output should be rendered
703: * @param jspFragmentOutput the result of having evaluated this tag's {@link javax.servlet.jsp.tagext.JspFragment}
704: */
705: protected void renderDataCellContents(
706: AbstractRenderAppender appender, String jspFragmentOutput) {
707: assert DECORATOR != null;
708: assert appender != null;
709: assert _imageAnchorCellModel != null;
710:
711: String script = null;
712: /* render any JavaScript needed to support framework features */
713: if (_imageState.id != null) {
714: HttpServletRequest request = JspUtil
715: .getRequest(getJspContext());
716: script = renderNameAndId(request, _imageState, null);
717: }
718:
719: /* render any JavaScript needed to support framework features */
720: if (_anchorState.id != null) {
721: HttpServletRequest request = JspUtil
722: .getRequest(getJspContext());
723: String anchorScript = renderNameAndId(request,
724: _anchorState, null);
725: if (anchorScript != null)
726: script = (script != null ? script += anchorScript
727: : anchorScript);
728: }
729:
730: _imageAnchorCellModel.setJavascript(script);
731:
732: DECORATOR.decorate(getJspContext(), appender,
733: _imageAnchorCellModel);
734: }
735:
736: /**
737: * Implementation of {@link AbstractHtmlTableCell#internalGetCellModel()} that exposes the
738: * {@link org.apache.beehive.netui.databinding.datagrid.runtime.model.cell.ImageAnchorCellModel}
739: * which is storing state for this tag.
740: * @return this tag's image anchor cell model
741: */
742: protected CellModel internalGetCellModel() {
743: return _imageAnchorCellModel;
744: }
745: }
|