KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tags > databinding > datagrid > ImageAnchorCell


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.netui.tags.databinding.datagrid;
19
20 import javax.servlet.jsp.JspException JavaDoc;
21 import javax.servlet.http.HttpServletRequest JavaDoc;
22
23 import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender;
24 import org.apache.beehive.netui.tags.rendering.AbstractHtmlState;
25 import org.apache.beehive.netui.tags.rendering.ImageTag;
26 import org.apache.beehive.netui.tags.rendering.AnchorTag;
27 import org.apache.beehive.netui.tags.html.HtmlConstants;
28 import org.apache.beehive.netui.tags.html.IFormattable;
29 import org.apache.beehive.netui.tags.html.IUrlParams;
30 import org.apache.beehive.netui.databinding.datagrid.api.rendering.CellModel;
31 import org.apache.beehive.netui.databinding.datagrid.runtime.model.cell.ImageAnchorCellModel;
32 import org.apache.beehive.netui.databinding.datagrid.runtime.rendering.cell.ImageAnchorCellDecorator;
33 import org.apache.beehive.netui.databinding.datagrid.runtime.util.JspUtil;
34 import org.apache.beehive.netui.util.ParamHelper;
35
36 /**
37  * <p>
38  * This tag is a data grid cell used to render an HTML image inside of an anchor. This tag should be used
39  * inside of a &lt;netui-data:rows&gt; tag when rendering a data set with the &lt;netui-data:dataGrid&gt; tag.
40  * The rendered output is structured as:
41  * <pre>
42  * &lt;a ...>&lt;img .../></a>
43  * </pre>
44  * If the {@link #setHref(String)} attribute is set, the href will be rendered on the anchor. If the {@link #setAction(String)}
45  * attribute is set, it must reference an action that is valid in the context of the current Page Flow. Only
46  * one of these two attributes may be set. The image source to render on the image tag is specified using the
47  * {@link #setSrc(String)} attribute.
48  * </p>
49  * <p>
50  * The set of JSP implicit objects available to the body include:
51  * <ul>
52  * <li><code>dataGridModel</code> -- the {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.DataGridTagModel}
53  * for the cell's containing data grid.</li>
54  * <li><code>container</code> -- the {@link org.apache.beehive.netui.script.common.IDataAccessProvider} instance
55  * that exposes the current data item and the current item's index</li>
56  * </ul>
57  * </p>
58  *
59  * @jsptagref.tagdescription
60  * <p>
61  * This tag is a data grid cell used to render an HTML image inside of an anchor. This tag should be used
62  * inside of a &lt;netui-data:rows&gt; tag when rendering a data set with the &lt;netui-data:dataGrid&gt; tag.
63  * The rendered output is structured as:
64  * <pre>
65  * &lt;a ...>&lt;img .../></a>
66  * </pre>
67  * If the {@link #setHref(String)} attribute is set, the href will be rendered on the anchor. If the {@link #setAction(String)}
68  * attribute is set, it must reference an action that is valid in the context of the current Page Flow. Only
69  * one of these two attributes may be set. The image source to render on the image tag is specified using the
70  * {@link #setSrc(String)} attribute.
71  * </p>
72  * <p>
73  * The set of JSP implicit objects available to the body include:
74  * <ul>
75  * <li><code>dataGridModel</code> -- the {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.DataGridTagModel}
76  * for the cell's containing data grid.</li>
77  * <li><code>container</code> -- the {@link org.apache.beehive.netui.script.common.IDataAccessProvider} instance
78  * that exposes the current data item and the current item's index</li>
79  * </ul>
80  * </p>
81  *
82  * @netui:tag name="imageAnchorCell" body-content="scriptless"
83  * description="Renders an HTML table cell in a data grid that contains an HTML image inside of an anchor."
84  */

85 public class ImageAnchorCell
86     extends AbstractHtmlTableCell
87     implements IFormattable, IUrlParams {
88
89     /*
90       todo: support rolloverImage on the <img> tags
91      */

92
93     private static final ImageAnchorCellDecorator DECORATOR = new ImageAnchorCellDecorator();
94     private static final String JavaDoc IMAGE_FACET_NAME = "image";
95     private static final String JavaDoc ANCHOR_FACET_NAME = "anchor";
96
97     private ImageAnchorCellModel _imageAnchorCellModel = new ImageAnchorCellModel();
98     private AnchorTag.State _anchorState = _imageAnchorCellModel.getAnchorState();
99     private ImageTag.State _imageState = _imageAnchorCellModel.getImageState();
100
101     /**
102      * The name of this tag; this value is used for error reporting.
103      * @return the String name of this tag
104      */

105     public String JavaDoc getTagName() {
106         return "ImageAnchorCell";
107     }
108
109     /**
110      * Sets the onClick JavaScript for the HTML anchor tag.
111      *
112      * @param onClick the onClick event.
113      * @jsptagref.attributedescription The onClick JavaScript for the HTML anchor tag.
114      * @jsptagref.attributesyntaxvalue <i>string_onClick</i>
115      * @netui:attribute required="false" rtexprvalue="true" description="The onClick JavaScript for the HTML anchor tag."
116      */

117     public void setOnClick(String JavaDoc onClick) {
118         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONCLICK, onClick);
119     }
120
121     /**
122      * Sets the onDblClick JavaScript for the HTML anchor tag.
123      *
124      * @param onDblClick the onDblClick event.
125      * @jsptagref.attributedescription The onDblClick JavaScript for the HTML anchor tag.
126      * @jsptagref.attributesyntaxvalue <i>string_onDblClick</i>
127      * @netui:attribute required="false" rtexprvalue="true" description="The onDblClick JavaScript for the HTML anchor tag."
128      */

129     public void setOnDblClick(String JavaDoc onDblClick) {
130         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONDBLCLICK, onDblClick);
131     }
132
133     /**
134      * Sets the onKeyDown JavaScript for the HTML anchor tag.
135      *
136      * @param onKeyDown the onKeyDown event.
137      * @jsptagref.attributedescription The onKeyDown JavaScript for the HTML anchor tag.
138      * @jsptagref.attributesyntaxvalue <i>string_onKeyDown</i>
139      * @netui:attribute required="false" rtexprvalue="true" description="The onKeyDown JavaScript for the HTML anchor tag."
140      */

141     public void setOnKeyDown(String JavaDoc onKeyDown) {
142         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONKEYDOWN, onKeyDown);
143     }
144
145     /**
146      * Sets the onKeyUp JavaScript for the HTML anchor tag.
147      *
148      * @param onKeyUp the onKeyUp event.
149      * @jsptagref.attributedescription The onKeyUp JavaScript for the HTML anchor tag.
150      * @jsptagref.attributesyntaxvalue <i>string_onKeyUp</i>
151      * @netui:attribute required="false" rtexprvalue="true" description="The onKeyUp JavaScript for the HTML anchor tag."
152      */

153     public void setOnKeyUp(String JavaDoc onKeyUp) {
154         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONKEYUP, onKeyUp);
155     }
156
157     /**
158      * Sets the onKeyPress JavaScript for the HTML anchor tag.
159      *
160      * @param onKeyPress the onKeyPress event.
161      * @jsptagref.attributedescription The onKeyPress JavaScript for the HTML anchor tag.
162      * @jsptagref.attributesyntaxvalue <i>string_onKeyPress</i>
163      * @netui:attribute required="false" rtexprvalue="true" description="The onKeyPress JavaScript for the HTML anchor tag."
164      */

165     public void setOnKeyPress(String JavaDoc onKeyPress) {
166         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONKEYPRESS, onKeyPress);
167     }
168
169     /**
170      * Sets the onMouseDown JavaScript for the HTML anchor tag.
171      *
172      * @param onMouseDown the onMouseDown event.
173      * @jsptagref.attributedescription The onMouseDown JavaScript for the HTML anchor tag.
174      * @jsptagref.attributesyntaxvalue <i>string_onMouseDown</i>
175      * @netui:attribute required="false" rtexprvalue="true" description="The onMouseDown JavaScript for the HTML anchor tag."
176      */

177     public void setOnMouseDown(String JavaDoc onMouseDown) {
178         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEDOWN, onMouseDown);
179     }
180
181     /**
182      * Sets the onMouseUp JavaScript for the HTML anchor tag.
183      *
184      * @param onMouseUp the onMouseUp event.
185      * @jsptagref.attributedescription The onMouseUp JavaScript for the HTML anchor tag.
186      * @jsptagref.attributesyntaxvalue <i>string_onMouseUp</i>
187      * @netui:attribute required="false" rtexprvalue="true" description="The onMouseUp JavaScript for the HTML anchor tag."
188      */

189     public void setOnMouseUp(String JavaDoc onMouseUp) {
190         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEUP, onMouseUp);
191     }
192
193     /**
194      * Sets the onMouseMove JavaScript for the HTML anchor tag.
195      *
196      * @param onMouseMove the onMouseMove event.
197      * @jsptagref.attributedescription The onMouseMove JavaScript for the HTML anchor tag.
198      * @jsptagref.attributesyntaxvalue <i>string_onMouseMove</i>
199      * @netui:attribute required="false" rtexprvalue="true" description="The onMouseMove JavaScript for the HTML anchor tag."
200      */

201     public void setOnMouseMove(String JavaDoc onMouseMove) {
202         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEMOVE, onMouseMove);
203     }
204
205     /**
206      * Sets the onMouseOut JavaScript for the HTML anchor tag.
207      *
208      * @param onMouseOut the onMouseOut event.
209      * @jsptagref.attributedescription The onMouseOut JavaScript for the HTML anchor tag.
210      * @jsptagref.attributesyntaxvalue <i>string_onMouseOut</i>
211      * @netui:attribute required="false" rtexprvalue="true" description="The onMouseOut JavaScript for the HTML anchor tag."
212      */

213     public void setOnMouseOut(String JavaDoc onMouseOut) {
214         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEOUT, onMouseOut);
215     }
216
217     /**
218      * Sets the onMouseOver JavaScript for the HTML anchor tag.
219      *
220      * @param onMouseOver the onMouseOver event.
221      * @jsptagref.attributedescription The onMouseOver JavaScript for the HTML anchor tag.
222      * @jsptagref.attributesyntaxvalue <i>string_onMouseOver</i>
223      * @netui:attribute required="false" rtexprvalue="true" description="The onMouseOver JavaScript for the HTML anchor tag."
224      */

225     public void setOnMouseOver(String JavaDoc onMouseOver) {
226         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEOVER, onMouseOver);
227     }
228
229     /**
230      * Sets the style of the rendered HTML anchor tag.
231      *
232      * @param style the html style.
233      * @jsptagref.attributedescription The style for the HTML anchor tag.
234      * @jsptagref.attributesyntaxvalue <i>string_style</i>
235      * @netui:attribute required="false" rtexprvalue="true" description="The style."
236      */

237     public void setStyle(String JavaDoc style) {
238         if("".equals(style)) return;
239
240         _anchorState.style = style;
241     }
242
243     /**
244      * Sets the style class of the rendered HTML anchor tag.
245      *
246      * @param styleClass the style class.
247      * @jsptagref.attributedescription The style class for the HTML anchor tag.
248      * @jsptagref.attributesyntaxvalue <i>string_style_class</i>
249      * @netui:attribute required="false" rtexprvalue="true" description="The style class for the HTML anchor tag."
250      */

251     public void setStyleClass(String JavaDoc styleClass) {
252         if("".equals(styleClass)) return;
253
254         _anchorState.styleClass = styleClass;
255     }
256
257     /**
258      * Sets the value of the title attribute for the HTML anchor tag.
259      *
260      * @param title the title
261      * @jsptagref.attributedescription The title for the HTML anchor tag.
262      * @jsptagref.attributesyntaxvalue <i>string_title</i>
263      * @netui:attribute required="false" rtexprvalue="true" description="The title for the HTML anchor tag."
264      */

265     public void setTitle(String JavaDoc title) {
266         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.TITLE, title);
267     }
268
269
270     /* ---------------------------------------------------------
271
272         Anchor specifc attributes
273
274        --------------------------------------------------------- */

275
276     /**
277      * Sets <code>charset</code> attribute for the HTML anchor tag
278      *
279      * @param charSet the charset
280      * @jsptagref.attributedescription The character set for the HTML anchor tag.
281      * @jsptagref.attributesyntaxvalue <i>string_charset</i>
282      * @netui:attribute required="false" rtexprvalue="true"
283      * description="The character set for the HTML anchor tag."
284      */

285     public void setCharSet(String JavaDoc charSet) {
286         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.CHARSET, charSet);
287     }
288
289     /**
290      * Sets <code>type</code> attribute for the HTML anchor tag.
291      *
292      * @param type the type
293      * @jsptagref.attributedescription The type attribute for the HTML anchor tag.
294      * @jsptagref.attributesyntaxvalue <i>string_type</i>
295      * @netui:attribute required="false" rtexprvalue="true"
296      * description="The type attribute for the HTML anchor tag."
297      */

298     public void setType(String JavaDoc type) {
299         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.TYPE, type);
300     }
301
302     /**
303      * Sets <code>hreflang</code> attribute for the HTML anchor tag.
304      *
305      * @param hreflang the hreflang.
306      * @jsptagref.attributedescription The hreflang attribute for the HTML anchor tag.
307      * @jsptagref.attributesyntaxvalue <i>string_hreflang</i>
308      * @netui:attribute required="false" rtexprvalue="true"
309      * description="The hreflang attribute for the HTML anchor tag."
310      */

311     public void setHrefLang(String JavaDoc hreflang) {
312         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.HREFLANG, hreflang);
313     }
314
315     /**
316      * Sets <code>rel</code> attribute for the HTML anchor tag.
317      *
318      * @param rel the rel attribute
319      * @jsptagref.attributedescription The rel attribute for the HTML anchor tag.
320      * @jsptagref.attributesyntaxvalue <i>string_rel</i>
321      * @netui:attribute required="false" rtexprvalue="true"
322      * description="The rel attribute for the HTML anchor tag."
323      */

324     public void setRel(String JavaDoc rel) {
325         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.REL, rel);
326     }
327
328     /**
329      * Sets <code>rev</code> attribute for the HTML anchor tag.
330      *
331      * @param rev the rev attribute.
332      * @jsptagref.attributedescription The rev attribute for the HTML anchor tag.
333      * @jsptagref.attributesyntaxvalue <i>string_rev</i>
334      * @netui:attribute required="false" rtexprvalue="true"
335      * description="The rev attribute for the HTML anchor tag."
336      */

337     public void setRev(String JavaDoc rev) {
338         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.REV, rev);
339     }
340
341
342     /**
343      * Sets the window target for the HTML anchor tag.
344      *
345      * @param target the window target
346      * @jsptagref.attributedescription The window target for the HTML anchor tag.
347      * @jsptagref.attributesyntaxvalue <i>string_action</i>
348      * @netui:attribute required="false" rtexprvalue="true"
349      * description="The window target for the HTML anchor tag."
350      */

351     public void setTarget(String JavaDoc target) {
352         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.TARGET, target);
353     }
354
355     /**
356      * Sets the href of the HTML anchor tag. This attribute will accept the empty String as a legal value.
357      *
358      * @param href the hyperlink URI for the anchor.
359      * @jsptagref.attributedescription The HREF for the HTML anchor tag.
360      * @jsptagref.attributesyntaxvalue <i>string_href</i>
361      * @netui:attribute required="false" rtexprvalue="true" reftype="url"
362      * description="The HREF for the HTML anchor tag."
363      */

364     public void setHref(String JavaDoc href) {
365         _imageAnchorCellModel.setHref(href);
366     }
367
368     /**
369      * Set the target "scope" for the anchor's action. Multiple active page flows may exist concurrently within named
370      * scopes. This attribute selects which named scope to use. If omitted, the default scope is assumed.
371      *
372      * @param targetScope the name of the target scope in which the associated action's page flow resides.
373      * @jsptagref.attributedescription The target scope in which the associated action's page flow resides.
374      * @jsptagref.attributesyntaxvalue <i>string_targetScope</i>
375      * @netui:attribute required="false" rtexprvalue="true"
376      * description="The target scope in which the associated action's page flow resides"
377      */

378     public void setTargetScope(String JavaDoc targetScope) {
379         _imageAnchorCellModel.setScopeId(targetScope);
380     }
381
382     /**
383      * Set the name of the action for the HTML anchor tag. This action name must be valid given the
384      * current Page Flow.
385      *
386      * @param action the name of the action to set for the anchor tag.
387      * @jsptagref.attributedescription The action method to invoke. The action method must valid given the
388      * ccurrent Page Flow.
389      * @jsptagref.attributesyntaxvalue <i>string_action</i>
390      * @netui:attribute required="false" rtexprvalue="true"
391      * description="The action method to invoke. The action method must be in the Controller file of the Page Flow directory."
392      */

393     public void setAction(String JavaDoc action)
394             throws JspException JavaDoc {
395         _imageAnchorCellModel.setAction(setRequiredValueAttribute(action, "action"));
396     }
397
398     /* ---------------------------------------------------------
399
400         Image specifc attributes
401
402        --------------------------------------------------------- */

403
404     /**
405      * Sets the alignment attribute for the HTML image tag.
406      *
407      * @param align the image alignment.
408      * @jsptagref.attributedescription The alignment attribute for the HTML image tag.
409      * @jsptagref.attributesyntaxvalue <i>string_align</i>
410      * @netui:attribute required="false" rtexprvalue="true"
411      * description="The alignment for the HTML image tag."
412      */

413     public void setAlign(String JavaDoc align) {
414         _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.ALIGN, align);
415     }
416
417     /**
418      * Sets the alt text attribute for the HTML image tag.
419      *
420      * @param alt the alt attribute.
421      * @jsptagref.attributedescription The alternative text of the HTML image tag.
422      * @jsptagref.attributesyntaxvalue <i>string_alt</i>
423      * @netui:attribute required="false" rtexprvalue="true"
424      * description="The alternative text of the HTML image tag."
425      */

426     public void setAlt(String JavaDoc alt) {
427         _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.ALT, alt);
428     }
429
430     /**
431      * Sets the longdesc attribute for the HTML image tag.
432      *
433      * @param longdesc the longdesc attribute
434      * @jsptagref.attributedescription The longdesc attribute for the HTML image tag.
435      * @jsptagref.attributesyntaxvalue <i>string_alt</i>
436      * @netui:attribute required="false" rtexprvalue="true"
437      * description="the longdesc for the HTML image tag."
438      */

439     public void setLongdesc(String JavaDoc longdesc) {
440         _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.LONGDESC, longdesc);
441     }
442
443     /**
444      * Sets the border size attribute for the HTML image tag.
445      *
446      * @param border the border size.
447      * @jsptagref.attributedescription The border size attribute for the HTML image tag.
448      * @jsptagref.attributesyntaxvalue <i>integer_pixelBorder</i>
449      * @netui:attribute required="false" rtexprvalue="true"
450      * description="The border size attribute for the HTML image tag."
451      */

452     public void setBorder(String JavaDoc border) {
453         _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.BORDER, border);
454     }
455
456     /**
457      * Sets the image height attribute for the HTML image tag.
458      *
459      * @param height the height.
460      * @jsptagref.attributedescription The image height attribute for the HTML image tag.
461      * @jsptagref.attributesyntaxvalue <i>integer_height</i>
462      * @netui:attribute required="false" rtexprvalue="true"
463      * description="The image height attribute for the HTML image tag."
464      */

465     public void setHeight(String JavaDoc height) {
466         _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.HEIGHT, height);
467     }
468
469     /**
470      * Sets the the horizontal spacing attribute for the HTML image tag.
471      *
472      * @param hspace the horizontal spacing.
473      * @jsptagref.attributedescription The horizontal spacing for the HTML image tag.
474      * @jsptagref.attributesyntaxvalue <i>integer_hspace</i>
475      * @netui:attribute required="false" rtexprvalue="true"
476      * description="The horizontal spacing for the HTML image tag."
477      */

478     public void setHspace(String JavaDoc hspace) {
479         _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.HSPACE, hspace);
480     }
481
482     /**
483      * Sets the server-side image map declaration for the HTML image tag.
484      *
485      * @param ismap the image map declaration.
486      * @jsptagref.attributedescription The server-side map declaration for the HTML image tag.
487      * @jsptagref.attributesyntaxvalue <i>string_isMap</i>
488      * @netui:attribute required="false" rtexprvalue="true"
489      * description="The server-side map declaration for the HTML image tag."
490      */

491     public void setIsmap(String JavaDoc ismap) {
492         _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.ISMAP, ismap);
493     }
494
495     /**
496      * Sets the image source URI for the HTML image tag.
497      *
498      * @param src the image source URI.
499      * @jsptagref.attributedescription The image source URI for the HTML image tag.
500      * @jsptagref.attributesyntaxvalue <i>string_src</i>
501      * @netui:attribute required="false" rtexprvalue="true"
502      * description="The image source URI for the HTML image tag" reftype="img-url"
503      */

504     public void setSrc(String JavaDoc src)
505             throws JspException JavaDoc {
506         _imageState.src = src;
507     }
508
509     /**
510      * Sets the client-side image map declaration for the HTML iage tag.
511      *
512      * @param usemap the map declaration.
513      * @jsptagref.attributedescription The client-side image map declaration for the HTML image tag.
514      * @jsptagref.attributesyntaxvalue <i>string_useMap</i>
515      * @netui:attribute required="false" rtexprvalue="true"
516      * description="The client-side image map declaration for the HTML image tag."
517      */

518     public void setUsemap(String JavaDoc usemap) {
519         _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.USEMAP, usemap);
520     }
521
522     /**
523      * Sets the vertical spacing around the HTML image tag.
524      *
525      * @param vspace the vertical spacing.
526      * @jsptagref.attributedescription The vertical spacing around the HTML image tag.
527      * @jsptagref.attributesyntaxvalue <i>string_vspace</i>
528      * @netui:attribute required="false" rtexprvalue="true"
529      * description="The vertical spacing around the HTML image tag."
530      */

531     public void setVspace(String JavaDoc vspace) {
532         _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.VSPACE, vspace);
533     }
534
535     /**
536      * Set the &lt;img> style for the contained image. When the tag library is
537      * running in legacy mode, this will override the <code>style</code> attribute if that is
538      * set. If this is not set, and <code>style</code> is set, then it will be applied to
539      * the image.
540      *
541      * @param imageStyle the image style
542      * @jsptagref.attributedescription The style for the HTML image tag.
543      * @jsptagref.attributesyntaxvalue <i>string_style</i>
544      * @netui:attribute required="false" rtexprvalue="true"
545      * description="Set the style for the HTML image tag."
546      */

547     public void setImageStyle(String JavaDoc imageStyle) {
548         _imageState.style = imageStyle;
549     }
550
551     /**
552      * Set the label style class for each contained Image. When the tag library is
553      * running in legacy mode, this will override the <code>styleClass</code> attribute if that is
554      * set. If this is not set, and <code>styleClass</code> is set, then it will be applied to
555      * the image.
556      *
557      * @param imageClass the image class
558      * @jsptagref.attributedescription The style class for the HTML image tag.
559      * @jsptagref.attributesyntaxvalue <i>string_style</i>
560      * @netui:attribute required="false" rtexprvalue="true"
561      * description="Set the style class for each contained image."
562      */

563     public void setImageStyleClass(String JavaDoc imageClass) {
564         _imageState.styleClass = imageClass;
565     }
566
567     /**
568      * Sets the width attribute for the HTML image tag.
569      *
570      * @param width the image width.
571      * @jsptagref.attributedescription The width for the HTML image tag.
572      * @jsptagref.attributesyntaxvalue <i>integer_pixelWidth</i>
573      * @netui:attribute required="false" rtexprvalue="true"
574      * description="The width attribute for the HTML image tag."
575      */

576     public void setWidth(String JavaDoc width) {
577         _imageState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.WIDTH, width);
578     }
579
580     /**
581      * Set the name of the tagId for the HTML image tag.
582      *
583      * @param tagId the the name of the tagId for the image.
584      * @jsptagref.attributedescription The tagId for the HTML image tag.
585      * @jsptagref.attributesyntaxvalue <i>string_tagId</i>
586      * @netui:attribute required="false" rtexprvalue="true"
587      * description="String value. Sets the id (or name) attribute of the rendered HTML tag. "
588      */

589     public void setTagId(String JavaDoc tagId)
590         throws JspException JavaDoc {
591         applyIndexedTagId(_imageState, tagId);
592     }
593
594     /**
595      * Set the name of the tagId for the HTML image tag..
596      *
597      * @param tagId the the name of the tagId for the image.
598      * @jsptagref.attributedescription The tagId for the HTML image tag.
599      * @jsptagref.attributesyntaxvalue <i>string_tagId</i>
600      * @netui:attribute required="false" rtexprvalue="true"
601      * description="String value. Sets the id (or name) attribute of the rendered HTML tag. "
602      */

603     public void setAnchorTagId(String JavaDoc tagId)
604         throws JspException JavaDoc {
605         applyIndexedTagId(_anchorState, tagId);
606     }
607
608     /**
609      * <p>
610      * Implementation of the {@link org.apache.beehive.netui.tags.IAttributeConsumer} interface. This
611      * allows users of this tag to extend the attribute set that is rendered by the HTML image or
612      * anchor tags. This method accepts the following facets:
613      * <table>
614      * <tr><td>Facet Name</td><td>Operation</td></tr>
615      * <tr><td><code>anchor</code></td><td>Adds an attribute with the provided <code>name</code> and <code>value</code> to the
616      * attributes rendered on the &lt;a&gt; tag.</td></tr>
617      * <tr><td><code>image</code></td><td>Adds an attribute with the provided <code>name</code> and <code>value</code> to the
618      * attributes rendered on the &lt;img&gt; tag.</td></tr>
619      * </table>
620      * This tag defaults to the setting attributes on the anchor when the facet name is unset.
621      * </p>
622      * @param name the name of the attribute
623      * @param value the value of the attribute
624      * @param facet the facet for the attribute
625      * @throws JspException thrown when the facet is not recognized
626      */

627     public void setAttribute(String JavaDoc name, String JavaDoc value, String JavaDoc facet)
628             throws JspException JavaDoc {
629         if(facet == null || facet.equals(ANCHOR_FACET_NAME))
630             super.addStateAttribute(_anchorState, name, value);
631         else if(facet.equals(IMAGE_FACET_NAME))
632             super.addStateAttribute(_imageState, name, value);
633         else
634             super.setAttribute(name, value, facet);
635     }
636
637     /**
638      * <p>
639      * Implementation of the {@link IUrlParams} interface. This allows this tag to accept &lt;netui:parameter&gt;
640      * and &lt;netui:parameterMap&gt; in order to add URL parameters onto the rendered anchor. For example:
641      * <pre>
642      * <netui-data:imageAnchorCell HREF="foo.jsp" SRC="foo.png">
643      * <netui:parameter name="paramKey" value="paramValue"/>
644      * </netui-data:anchorCell>
645      * </pre>
646      * will render an HTML image anchor as:
647      * <pre>
648      * <a HREF="foo.jsp?paramKey=paramValue><img SRC="foo.png"/></a>
649      * </pre>
650      * </p>
651      * @param name the name of the parameter
652      * @param value the value of the parameter
653      * @param facet the facet for the parameter
654      * @throws JspException thrown when the facet is unsupported
655      */

656     public void addParameter(String JavaDoc name, Object JavaDoc value, String JavaDoc facet)
657             throws JspException JavaDoc {
658         ParamHelper.addParam(_imageAnchorCellModel.getParams(), name, value);
659     }
660
661     /**
662      * Render the contents of the HTML anchor and image. This method calls to an
663      * {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.CellDecorator} associated with this tag.
664      * The result of renderingi is appended to the <code>appender</code>
665      * @param appender the {@link AbstractRenderAppender} to which output should be rendered
666      * @param jspFragmentOutput the result of having evaluated this tag's {@link javax.servlet.jsp.tagext.JspFragment}
667      */

668     protected void renderDataCellContents(AbstractRenderAppender appender, String JavaDoc jspFragmentOutput) {
669         assert DECORATOR != null;
670         assert appender != null;
671         assert _imageAnchorCellModel != null;
672
673         String JavaDoc script = null;
674         /* render any JavaScript needed to support framework features */
675         if (_imageState.id != null) {
676             HttpServletRequest JavaDoc request = JspUtil.getRequest(getJspContext());
677             script = renderNameAndId(request, _imageState, null);
678         }
679
680         /* render any JavaScript needed to support framework features */
681         if (_anchorState.id != null) {
682             HttpServletRequest JavaDoc request = JspUtil.getRequest(getJspContext());
683             String JavaDoc anchorScript = renderNameAndId(request, _anchorState, null);
684             if(anchorScript != null)
685                 script = (script != null ? script += anchorScript : anchorScript);
686         }
687
688         _imageAnchorCellModel.setJavascript(script);
689
690         DECORATOR.decorate(getJspContext(), appender, _imageAnchorCellModel);
691     }
692
693     /**
694      * Implementation of {@link AbstractHtmlTableCell#internalGetCellModel()} that exposes the
695      * {@link org.apache.beehive.netui.databinding.datagrid.runtime.model.cell.ImageAnchorCellModel}
696      * which is storing state for this tag.
697      * @return this tag's image anchor cell model
698      */

699     protected CellModel internalGetCellModel() {
700         return _imageAnchorCellModel;
701     }
702 }
703
Popular Tags