KickJava   Java API By Example, From Geeks To Geeks.

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


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.databinding.datagrid.api.rendering.CellModel;
24 import org.apache.beehive.netui.databinding.datagrid.runtime.model.cell.AnchorCellModel;
25 import org.apache.beehive.netui.databinding.datagrid.runtime.rendering.cell.AnchorCellDecorator;
26 import org.apache.beehive.netui.databinding.datagrid.runtime.util.JspUtil;
27 import org.apache.beehive.netui.tags.html.IUrlParams;
28 import org.apache.beehive.netui.tags.html.HtmlConstants;
29 import org.apache.beehive.netui.tags.html.IFormattable;
30 import org.apache.beehive.netui.tags.rendering.AbstractHtmlState;
31 import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender;
32 import org.apache.beehive.netui.tags.rendering.AnchorTag;
33 import org.apache.beehive.netui.tags.IHtmlI18n;
34 import org.apache.beehive.netui.tags.IHtmlEvents;
35 import org.apache.beehive.netui.tags.IHtmlCore;
36 import org.apache.beehive.netui.util.ParamHelper;
37 import org.apache.beehive.netui.util.Bundle;
38
39 /**
40  * <p>
41  * Data grid cell used to render an HTML anchor. This tag should be used inside of a &lt;netui-data:rows&gt; tag
42  * when rendering a data set with the &lt;netui-data:dataGrid&gt; tag. An AnchorCell is used to render an HTML
43  * &lt;a&gt; tag. The rendered href is provided with either the action or href attributes. If an action is provided,
44  * the action must exist inside of the 'current' Page Flow with which the JSP is associated. If the href is provided,
45  * the anchor will use this value as its rendered href. For example:
46  * <pre>
47  * &lt;netui-data:anchorCell HREF="foo.jsp" value="Go To Foo"/>
48  * </pre>
49  * will render:
50  * <pre>
51  * &lt;a HREF="foo.jsp">Go To Foo&lt;/a>
52  * </pre>
53  * </p>
54  * <p>
55  * The AnchorCell tag can also accept NetUI parameter tags that implement the {@link IUrlParams} interface. When
56  * these tags are contained inside of this tag, they add URL parameters onto the rendered href. For example:
57  * <pre>
58  * <netui-data:anchorCell HREF="foo.jsp" value="Go To Foo">
59  * <netui:parameter name="paramKey" value="paramValue"/>
60  * </netui-data:anchorCell>
61  * </pre>
62  * will render:
63  * <pre>
64  * &lt;a HREF="foo.jsp?paramKey=paramValue">Go To Foo&lt;/a>
65  * </pre>
66  * </p>
67  * <p>
68  * The set of JSP implicit objects available to the body include:
69  * <ul>
70  * <li><code>dataGridModel</code> -- the {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.DataGridTagModel}
71  * for the cell's containing data grid.</li>
72  * <li><code>container</code> -- the {@link org.apache.beehive.netui.script.common.IDataAccessProvider} instance
73  * that exposes the current data item and the current item's index</li>
74  * </ul>
75  * </p>
76  *
77  * @jsptagref.tagdescription
78  * <p>
79  * Data grid cell used to render an HTML anchor. This tag should be used inside of a &lt;netui-data:rows&gt; tag
80  * when rendering a data set with the &lt;netui-data:dataGrid&gt; tag. An AnchorCell is used to render an HTML
81  * &lt;a&gt; tag. The rendered href is provided with either the action or href attributes. If an action is provided,
82  * the action must exist inside of the 'current' Page Flow with which the JSP is associated. If the href is provided,
83  * the anchor will use this value as its rendered href. For example:
84  * <pre>
85  * &lt;netui-data:anchorCell HREF="foo.jsp" value="Go To Foo"/>
86  * </pre>
87  * will render:
88  * <pre>
89  * &lt;a HREF="foo.jsp">Go To Foo&lt;/a>
90  * </pre>
91  * </p>
92  * <p>
93  * The AnchorCell tag can also accept NetUI parameter tags that implement the {@link IUrlParams} interface. When
94  * these tags are contained inside of this tag, they add URL parameters onto the rendered href. For example:
95  * <pre>
96  * &lt;netui-data:anchorCell HREF="foo.jsp" value="Go To Foo">
97  * &lt;netui:parameter name="paramKey" value="paramValue"/>
98  * &lt;/netui-data:anchorCell>
99  * </pre>
100  * will render:
101  * <pre>
102  * &lt;a HREF="foo.jsp?paramKey=paramValue">Go To Foo&lt;/a>
103  * </pre>
104  * </p>
105  * <p>
106  * The set of JSP implicit objects available to the body include:
107  * <ul>
108  * <li><code>dataGridModel</code> -- the {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.DataGridTagModel}
109  * for the cell's containing data grid.</li>
110  * <li><code>container</code> -- the {@link org.apache.beehive.netui.script.common.IDataAccessProvider} instance
111  * that exposes the current data item and the current item's index</li>
112  * </ul>
113  * </p>
114  *
115  * @netui:tag name="anchorCell" body-content="scriptless"
116  * description="Renders an HTML table cell inside of a data grid that contains an anchor"
117  */

118 public class AnchorCell
119     extends AbstractHtmlTableCell
120     implements IFormattable, IUrlParams, IHtmlCore, IHtmlEvents, IHtmlI18n {
121
122     private static final AnchorCellDecorator DECORATOR = new AnchorCellDecorator();
123     private static final String JavaDoc REQUIRED_ATTR = "href, action, linkName";
124     private static final String JavaDoc ANCHOR_FACET_NAME = "anchor";
125
126     private AnchorCellModel _anchorCellModel = new AnchorCellModel();
127     private AnchorTag.State _anchorState = _anchorCellModel.getAnchorState();
128
129     /**
130      * The name of this tag; this value is used for error reporting.
131      * @return the String name of this tag
132      */

133     public String JavaDoc getTagName() {
134         return "AnchorCell";
135     }
136
137     /**
138      * Sets the onClick JavaScript event for the HTML anchor.
139      *
140      * @param onClick the onClick event for the HTML anchor.
141      * @jsptagref.attributedescription The onClick JavaScript event for the HTML anchor.
142      * @jsptagref.attributesyntaxvalue <i>string_onClick</i>
143      * @netui:attribute required="false" rtexprvalue="true" description="The onClick JavaScript event."
144      */

145     public void setOnClick(String JavaDoc onClick) {
146         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONCLICK, onClick);
147     }
148
149     /**
150      * Sets the onDblClick JavaScript event for the HTML anchor.
151      *
152      * @param onDblClick the onDblClick event.
153      * @jsptagref.attributedescription The onDblClick JavaScript event for the HTML anchor.
154      * @jsptagref.attributesyntaxvalue <i>string_onDblClick</i>
155      * @netui:attribute required="false" rtexprvalue="true" description="The onDblClick JavaScript event."
156      */

157     public void setOnDblClick(String JavaDoc onDblClick) {
158         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONDBLCLICK, onDblClick);
159     }
160
161     /**
162      * Sets the onKeyDown JavaScript event for the HTML anchor.
163      *
164      * @param onKeyDown the onKeyDown event.
165      * @jsptagref.attributedescription The onKeyDown JavaScript event for the HTML anchor.
166      * @jsptagref.attributesyntaxvalue <i>string_onKeyDown</i>
167      * @netui:attribute required="false" rtexprvalue="true" description="The onKeyDown JavaScript event."
168      */

169     public void setOnKeyDown(String JavaDoc onKeyDown) {
170         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONKEYDOWN, onKeyDown);
171     }
172
173     /**
174      * Sets the onKeyUp JavaScript event for the HTML anchor.
175      *
176      * @param onKeyUp the onKeyUp event.
177      * @jsptagref.attributedescription The onKeyUp JavaScript event for the HTML anchor.
178      * @jsptagref.attributesyntaxvalue <i>string_onKeyUp</i>
179      * @netui:attribute required="false" rtexprvalue="true" description="The onKeyUp JavaScript event."
180      */

181     public void setOnKeyUp(String JavaDoc onKeyUp) {
182         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONKEYUP, onKeyUp);
183     }
184
185     /**
186      * Sets the onKeyPress JavaScript event for the HTML anchor.
187      *
188      * @param onKeyPress the onKeyPress event.
189      * @jsptagref.attributedescription The onKeyPress JavaScript event for the HTML anchor.
190      * @jsptagref.attributesyntaxvalue <i>string_onKeyPress</i>
191      * @netui:attribute required="false" rtexprvalue="true" description="The onKeyPress JavaScript event."
192      */

193     public void setOnKeyPress(String JavaDoc onKeyPress) {
194         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONKEYPRESS, onKeyPress);
195     }
196
197     /**
198      * Sets the onMouseDown JavaScript event for the HTML anchor.
199      *
200      * @param onMouseDown the onMouseDown event.
201      * @jsptagref.attributedescription The onMouseDown JavaScript event for the HTML anchor.
202      * @jsptagref.attributesyntaxvalue <i>string_onMouseDown</i>
203      * @netui:attribute required="false" rtexprvalue="true" description="The onMouseDown JavaScript event."
204      */

205     public void setOnMouseDown(String JavaDoc onMouseDown) {
206         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEDOWN, onMouseDown);
207     }
208
209     /**
210      * Sets the onMouseUp JavaScript event for the HTML anchor.
211      *
212      * @param onMouseUp the onMouseUp event.
213      * @jsptagref.attributedescription The onMouseUp JavaScript event for the HTML anchor.
214      * @jsptagref.attributesyntaxvalue <i>string_onMouseUp</i>
215      * @netui:attribute required="false" rtexprvalue="true" description="The onMouseUp JavaScript event."
216      */

217     public void setOnMouseUp(String JavaDoc onMouseUp) {
218         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEUP, onMouseUp);
219     }
220
221     /**
222      * Sets the onMouseMove JavaScript event for the HTML anchor.
223      *
224      * @param onMouseMove the onMouseMove event.
225      * @jsptagref.attributedescription The onMouseMove JavaScript event for the HTML anchor.
226      * @jsptagref.attributesyntaxvalue <i>string_onMouseMove</i>
227      * @netui:attribute required="false" rtexprvalue="true" description="The onMouseMove JavaScript event."
228      */

229     public void setOnMouseMove(String JavaDoc onMouseMove) {
230         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEMOVE, onMouseMove);
231     }
232
233     /**
234      * Sets the onMouseOut JavaScript event for the HTML anchor.
235      *
236      * @param onMouseOut the onMouseOut event.
237      * @jsptagref.attributedescription The onMouseOut JavaScript event for the HTML anchor.
238      * @jsptagref.attributesyntaxvalue <i>string_onMouseOut</i>
239      * @netui:attribute required="false" rtexprvalue="true" description="The onMouseOut JavaScript event."
240      */

241     public void setOnMouseOut(String JavaDoc onMouseOut) {
242         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEOUT, onMouseOut);
243     }
244
245     /**
246      * Sets the onMouseOver JavaScript event for the HTML anchor.
247      *
248      * @param onMouseOver the onMouseOver event.
249      * @jsptagref.attributedescription The onMouseOver JavaScript event for the HTML anchor.
250      * @jsptagref.attributesyntaxvalue <i>string_onMouseOver</i>
251      * @netui:attribute required="false" rtexprvalue="true" description="The onMouseOver JavaScript event."
252      */

253     public void setOnMouseOver(String JavaDoc onMouseOver) {
254         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONMOUSEOVER, onMouseOver);
255     }
256
257     /**
258      * Sets the style of the HTML anchor.
259      *
260      * @param style the style attribute
261      * @jsptagref.attributedescription The style for the HTML anchor.
262      * @jsptagref.attributesyntaxvalue <i>string_style</i>
263      * @netui:attribute required="false" rtexprvalue="true" description="The style for the HTML anchor"
264      */

265     public void setStyle(String JavaDoc style) {
266         if("".equals(style)) return;
267
268         _anchorState.style = style;
269     }
270
271     /**
272      * Sets the style class of the HTML anchor.
273      *
274      * @param styleClass the style attribute.
275      * @jsptagref.attributedescription The style class for the HTML anchor.
276      * @jsptagref.attributesyntaxvalue <i>string_style_class</i>
277      * @netui:attribute required="false" rtexprvalue="true" description="The style class for the anchor"
278      */

279     public void setStyleClass(String JavaDoc styleClass) {
280         if("".equals(styleClass)) return;
281
282         _anchorState.styleClass = styleClass;
283     }
284
285     /**
286      * Sets the value of the title attribute for the HTML anchor
287      *
288      * @param title the title attribute
289      * @jsptagref.attributedescription The title attribute for the HTML anchor.
290      * @jsptagref.attributesyntaxvalue <i>string_title</i>
291      * @netui:attribute required="false" rtexprvalue="true" description="The title attribute for the anchor"
292      */

293     public void setTitle(String JavaDoc title) {
294         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.TITLE, title);
295     }
296
297     /**
298      * Sets <code>charset</code> attribute for the HTML anchor.
299      *
300      * @param charSet the charSet attribute for the HTML anchor.
301      * @jsptagref.attributedescription The charSet attribute for the HTML anchor.
302      * @jsptagref.attributesyntaxvalue <i>string_charset</i>
303      * @netui:attribute required="false" rtexprvalue="true" description="The character set."
304      */

305     public void setCharset(String JavaDoc charSet) {
306         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.CHARSET, charSet);
307     }
308
309     /**
310      * Sets <code>type</code> attribute for the HTML anchor.
311      *
312      * @param type the type attribute
313      * @jsptagref.attributedescription The type attribute for the HTML anchor.
314      * @jsptagref.attributesyntaxvalue <i>string_type</i>
315      * @netui:attribute required="false" rtexprvalue="true" description="The attribute for the HTML anchor"
316      */

317     public void setType(String JavaDoc type) {
318         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.TYPE, type);
319     }
320
321     /**
322      * Sets <code>hreflang</code> attribute for the anchor.
323      *
324      * @param hreflang the hreflang attribute
325      * @jsptagref.attributedescription The hrefLang attribute for the HTML anchor.
326      * @jsptagref.attributesyntaxvalue <i>string_hreflang</i>
327      * @netui:attribute required="false" rtexprvalue="true" description="The HREF lang attribute for the HTML anchor."
328      */

329     public void setHrefLang(String JavaDoc hreflang) {
330         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.HREFLANG, hreflang);
331     }
332
333     /**
334      * Sets <code>rel</code> attribute for the HTML anchor.
335      *
336      * @param rel the rel attribute
337      * @jsptagref.attributedescription The rel attribute for the HTML anchor.
338      * @jsptagref.attributesyntaxvalue <i>string_rel</i>
339      * @netui:attribute required="false" rtexprvalue="true" description="The rel for the HTML anchor."
340      */

341     public void setRel(String JavaDoc rel) {
342         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.REL, rel);
343     }
344
345     /**
346      * Sets <code>rev</code> attribute for the HTML anchor.
347      *
348      * @param rev the rev target for the HTML anchor
349      * @jsptagref.attributedescription The rev for the HTML anchor.
350      * @jsptagref.attributesyntaxvalue <i>string_rev</i>
351      * @netui:attribute required="false" rtexprvalue="true" description="The rev for the HTML anchor."
352      */

353     public void setRev(String JavaDoc rev) {
354         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.REV, rev);
355     }
356
357     /**
358      * Sets the window target for the HTML anchor.
359      *
360      * @param target the window target for the HTML anchor.
361      * @jsptagref.attributedescription The window target for the HTML anchor.
362      * @jsptagref.attributesyntaxvalue <i>string_target</i>
363      * @netui:attribute required="false" rtexprvalue="true" description="The window target."
364      */

365     public void setTarget(String JavaDoc target) {
366         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.TARGET, target);
367     }
368
369     /**
370      * Sets the href of the HTML anchor. This attribute will accept the empty String as a legal value.
371      *
372      * @param href the hyperlink URI for the HTML anchor.
373      * @jsptagref.attributedescription The URL to go to.
374      * @jsptagref.attributesyntaxvalue <i>string_href</i>
375      * @netui:attribute required="false" rtexprvalue="true"
376      * description="The href of the HTML anchor."
377      */

378     public void setHref(String JavaDoc href) {
379         _anchorCellModel.setHref(href);
380     }
381
382     /**
383      * Set the target "scope" for the anchor's action. Multiple active page flows may exist concurrently within named
384      * scopes. This attribute selects which named scope to use. If omitted, the default scope is assumed.
385      *
386      * @param targetScope the name of the target scope in which the associated action's page flow resides.
387      * @jsptagref.attributedescription The target scope in which the associated action's page flow resides.
388      * @jsptagref.attributesyntaxvalue <i>string_targetScope</i>
389      * @netui:attribute required="false" rtexprvalue="true" description="The target scope in which the associated action's page flow resides"
390      */

391     public void setTargetScope(String JavaDoc targetScope) {
392         _anchorCellModel.setScopeId(targetScope);
393     }
394
395     /**
396      * The text displayed for the HTML anchor.
397      * @param value the text displayed for the HTML anchor
398      * @jsptagref.attributedescription the text displayed for the HTML anchor
399      * @jsptagref.attributesyntaxvalue <i>string_value</i>
400      * @netui:attribute required="true" rtexprvalue="true"
401      */

402     public void setValue(String JavaDoc value) {
403         _anchorCellModel.setValue(value);
404     }
405
406     /**
407      * Set the name of the action for the HTML anchor. The action method must be in the Page Flow with which
408      * the containing JSP is associated.
409      *
410      * @param action the name of the action to set for the Area.
411      * @jsptagref.attributedescription The action method to invoke. The action method must be in Page Flow with which
412      * the containing JSP is associated.
413      * @jsptagref.attributesyntaxvalue <i>string_action</i>
414      * @netui:attribute required="false" rtexprvalue="true"
415      * description="The action method to invoke. The action method must be in the Page Flow with wihch the containing JSP
416      * is associated.
417      */

418     public void setAction(String JavaDoc action)
419         throws JspException JavaDoc {
420         _anchorCellModel.setAction(setRequiredValueAttribute(action, "action"));
421     }
422
423     /**
424      * Sets the lang attribute for the HTML anchor.
425      * @param lang
426      * @jsptagref.attributedescription The lang attribute for the HTML anchor.
427      * @jsptagref.attributesyntaxvalue <i>string_lang</i>
428      * @netui:attribute required="false" rtexprvalue="true" description="The lang for the HTML anchor."
429      */

430     public void setLang(String JavaDoc lang)
431     {
432         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.LANG, lang);
433     }
434
435     /**
436      * Sets the dir attribute for the HTML anchor.
437      * @param dir
438      * @jsptagref.attributedescription The dir attribute for the HTML anchor.
439      * @jsptagref.attributesyntaxvalue <i>string_dir</i>
440      * @netui:attribute required="false" rtexprvalue="true" description="The dir attribute for the HTML anchor."
441      */

442     public void setDir(String JavaDoc dir)
443     {
444         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.DIR, dir);
445     }
446
447     /**
448      * Sets the accessKey attribute value. This should key value of the
449      * keyboard navigation key. It is recommended not to use the following
450      * values because there are often used by browsers <code>A, C, E, F, G,
451      * H, V, left arrow, and right arrow</code>.
452      * @param accessKey the accessKey value.
453      * @jsptagref.attributedescription The keyboard navigation key for the element.
454      * The following values are not recommended because they
455      * are often used by browsers: <code>A, C, E, F, G,
456      * H, V, left arrow, and right arrow</code>
457      * @jsptagref.attributesyntaxvalue <i>string_accessKey</i>
458      * @netui:attribute required="false" rtexprvalue="true" type="char"
459      * description=" The keyboard navigation key for the element.
460      * The following values are not recommended because they
461      * are often used by browsers: A, C, E, F, G,
462      * H, V, left arrow, and right arrow."
463      */

464     public void setAccessKey(char accessKey) {
465         if (accessKey == 0x00)
466             return;
467         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.ACCESSKEY, Character.toString(accessKey));
468     }
469
470     /**
471      * Sets the tabIndex of the rendered html tag.
472      * @param tabindex the tab index.
473      * @jsptagref.attributedescription The tabIndex of the rendered HTML tag. This attribute determines the position of the
474      * rendered HTML tag in the sequence of tags that the user may advance through by pressing the TAB key.
475      * @jsptagref.attributesyntaxvalue <i>string_tabIndex</i>
476      * @netui:attribute required="false" rtexprvalue="true" type="int"
477      * description="The tabIndex of the rendered HTML tag. This attribute determines the position of the
478      * rendered HTML tag in the sequence of tags that the user may advance through by pressing the TAB key."
479      */

480     public void setTabindex(int tabindex) {
481         _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.TABINDEX, Integer.toString(tabindex));
482     }
483
484     /**
485      * Sets the onBlur JavaScript event for the HTML anchor.
486      * @param onblur the onBlur event.
487      * @jsptagref.attributedescription The onBlur JavaScript event for the HTML anchor.
488      * @jsptagref.attributesyntaxvalue <i>string_onBlur</i>
489      * @netui:attribute required="false" rtexprvalue="true"
490      * description="The onBlur JavaScript event."
491      */

492     public void setOnBlur(String JavaDoc onblur)
493     {
494         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONBLUR, onblur);
495     }
496
497     /**
498      * Sets the onFocus JavaScript event for the HTML anchor.
499      * @param onfocus the onFocus event.
500      * @jsptagref.attributedescription The onFocus JavaScript event for the HTML anchor.
501      * @jsptagref.attributesyntaxvalue <i>string_onFocus</i>
502      * @netui:attribute required="false" rtexprvalue="true"
503      * description="The onFocus JavaScript event."
504      */

505     public void setOnFocus(String JavaDoc onfocus)
506     {
507         _anchorState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, HtmlConstants.ONFOCUS, onfocus);
508     }
509
510     /**
511      * <p>
512      * Set the name of the tagId for the HTML anchor. The provided tagId will have the index of the current
513      * row added as a suffix in order to keep the anchor tagIds unique in the page.
514      * </p>
515      *
516      * @param tagId the the tagId for the HTML anchor.
517      * @jsptagref.attributedescription The tagId.
518      * @jsptagref.attributesyntaxvalue <i>string_tagId</i>
519      * @netui:attribute required="false" rtexprvalue="true"
520      * description="String value. Sets the id (or name) attribute of the rendered HTML tag. "
521      */

522     public void setTagId(String JavaDoc tagId)
523         throws JspException JavaDoc {
524         applyIndexedTagId(_anchorState, tagId);
525     }
526
527     /**
528      * <p>
529      * Implementation of the {@link org.apache.beehive.netui.tags.IAttributeConsumer} interface. This
530      * allows users of the anchorCell tag to extend the attribute set that is rendered by the HTML
531      * anchor. This method accepts the following facets:
532      * <table>
533      * <tr><td>Facet Name</td><td>Operation</td></tr>
534      * <tr><td><code>anchor</code></td><td>Adds an attribute with the provided <code>name</code> and <code>value</code> to the
535      * attributes rendered on the &lt;a&gt; tag.</td></tr>
536      * </table>
537      * The AnchorCell tag defaults to the setting attributes on the anchor when the facet name is unset.
538      * </p>
539      * @param name the name of the attribute
540      * @param value the value of the attribute
541      * @param facet the facet for the attribute
542      * @throws JspException thrown when the facet is not recognized
543      */

544     public void setAttribute(String JavaDoc name, String JavaDoc value, String JavaDoc facet)
545             throws JspException JavaDoc {
546         if(facet == null || facet.equals(ANCHOR_FACET_NAME))
547             super.addStateAttribute(_anchorState, name, value);
548         else
549             super.setAttribute(name, value, facet);
550     }
551
552     /**
553      * <p>
554      * Implementation of the {@link IUrlParams} interface. This allows this tag to accept &lt;netui:parameter&gt;
555      * and &lt;netui:parameterMap&gt; in order to add URL parameters onto the rendered anchor. For example:
556      * <pre>
557      * <netui-data:anchorCell HREF="foo.jsp" value="Go To Foo">
558      * <netui:parameter name="paramKey" value="paramValue"/>
559      * </netui-data:anchorCell>
560      * </pre>
561      * will render an HTML anchor as:
562      * <pre>
563      * <a HREF="foo.jsp?paramKey=paramValue>Go To Foo</a>
564      * </pre>
565      * </p>
566      * @param name the name of the parameter
567      * @param value the value of the parameter
568      * @param facet the facet for the parameter
569      * @throws JspException thrown when the facet is unsupported
570      */

571     public void addParameter(String JavaDoc name, Object JavaDoc value, String JavaDoc facet)
572             throws JspException JavaDoc {
573         ParamHelper.addParam(_anchorCellModel.getParams(), name, value);
574     }
575
576     /**
577      * <p>
578      * Interanl method overriding the {@link AbstractHtmlTableCell#applyAttributes()} method
579      * to handle setting attributes on the {@link AnchorCellModel} associated with an instance of this tag.
580      * </p>
581      * @throws JspException when an error occurs applying attributes to the cell model.
582      */

583     protected void applyAttributes()
584             throws JspException JavaDoc {
585         super.applyAttributes();
586
587         int have = 0;
588         if(_anchorCellModel.getAction() != null)
589             have++;
590         if(_anchorCellModel.getHref() != null)
591             have++;
592         if(_anchorCellModel.getLinkName() != null)
593             have++;
594
595         /* todo: allow creation of JavaScript anchors */
596         if(have == 0 || have > 1) {
597             String JavaDoc s = Bundle.getString("Tags_Anchor_InvalidAnchorURI", new Object JavaDoc[]{getTagName(),REQUIRED_ATTR});
598             throw new JspException JavaDoc(s);
599         }
600     }
601
602     /**
603      * Render the contents of the HTML anchor. This method calls to an
604      * {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.CellDecorator} associated with this tag.
605      * The result of renderingi is appended to the <code>appender</code>
606      * @param appender the {@link AbstractRenderAppender} to which output should be rendered
607      * @param jspFragmentOutput the result of having evaluated this tag's {@link javax.servlet.jsp.tagext.JspFragment}
608      */

609     protected void renderDataCellContents(AbstractRenderAppender appender, String JavaDoc jspFragmentOutput) {
610
611         /* render any JavaScript needed to support framework features */
612         if (_anchorState.id != null) {
613             HttpServletRequest JavaDoc request = JspUtil.getRequest(getJspContext());
614             String JavaDoc script = renderNameAndId(request, _anchorState, null);
615             _anchorCellModel.setJavascript(script);
616         }
617
618         DECORATOR.decorate(getJspContext(), appender, _anchorCellModel);
619     }
620
621     /**
622      * Implementation of {@link AbstractHtmlTableCell#internalGetCellModel()} that exposes the {@link AnchorCellModel}
623      * which is storing state for the tag's anchor.
624      * @return this tag's anchor cell model
625      */

626     protected CellModel internalGetCellModel() {
627         return _anchorCellModel;
628     }
629 }
630
Popular Tags