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.databinding.datagrid.api.rendering.CellModel;
025: import org.apache.beehive.netui.databinding.datagrid.runtime.model.cell.AnchorCellModel;
026: import org.apache.beehive.netui.databinding.datagrid.runtime.rendering.cell.AnchorCellDecorator;
027: import org.apache.beehive.netui.databinding.datagrid.runtime.util.JspUtil;
028: import org.apache.beehive.netui.tags.html.IUrlParams;
029: import org.apache.beehive.netui.tags.html.HtmlConstants;
030: import org.apache.beehive.netui.tags.html.IFormattable;
031: import org.apache.beehive.netui.tags.rendering.AbstractHtmlState;
032: import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender;
033: import org.apache.beehive.netui.tags.rendering.AnchorTag;
034: import org.apache.beehive.netui.tags.IHtmlI18n;
035: import org.apache.beehive.netui.tags.IHtmlEvents;
036: import org.apache.beehive.netui.tags.IHtmlCore;
037: import org.apache.beehive.netui.util.ParamHelper;
038: import org.apache.beehive.netui.util.Bundle;
039:
040: /**
041: * <p>
042: * Data grid cell used to render an HTML anchor. This tag should be used inside of a <netui-data:rows> tag
043: * when rendering a data set with the <netui-data:dataGrid> tag. An AnchorCell is used to render an HTML
044: * <a> tag. The rendered href is provided with either the action or href attributes. If an action is provided,
045: * the action must exist inside of the 'current' Page Flow with which the JSP is associated. If the href is provided,
046: * the anchor will use this value as its rendered href. For example:
047: * <pre>
048: * <netui-data:anchorCell href="foo.jsp" value="Go To Foo"/>
049: * </pre>
050: * will render:
051: * <pre>
052: * <a href="foo.jsp">Go To Foo</a>
053: * </pre>
054: * </p>
055: * <p>
056: * The AnchorCell tag can also accept NetUI parameter tags that implement the {@link IUrlParams} interface. When
057: * these tags are contained inside of this tag, they add URL parameters onto the rendered href. For example:
058: * <pre>
059: * <netui-data:anchorCell href="foo.jsp" value="Go To Foo">
060: * <netui:parameter name="paramKey" value="paramValue"/>
061: * </netui-data:anchorCell>
062: * </pre>
063: * will render:
064: * <pre>
065: * <a href="foo.jsp?paramKey=paramValue">Go To Foo</a>
066: * </pre>
067: * </p>
068: * <p>
069: * The set of JSP implicit objects available to the body include:
070: * <ul>
071: * <li><code>dataGridModel</code> -- the {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.DataGridTagModel}
072: * for the cell's containing data grid.</li>
073: * <li><code>container</code> -- the {@link org.apache.beehive.netui.script.common.IDataAccessProvider} instance
074: * that exposes the current data item and the current item's index</li>
075: * </ul>
076: * </p>
077: *
078: * @jsptagref.tagdescription
079: * <p>
080: * Data grid cell used to render an HTML anchor. This tag should be used inside of a <netui-data:rows> tag
081: * when rendering a data set with the <netui-data:dataGrid> tag. An AnchorCell is used to render an HTML
082: * <a> tag. The rendered href is provided with either the action or href attributes. If an action is provided,
083: * the action must exist inside of the 'current' Page Flow with which the JSP is associated. If the href is provided,
084: * the anchor will use this value as its rendered href. For example:
085: * <pre>
086: * <netui-data:anchorCell href="foo.jsp" value="Go To Foo"/>
087: * </pre>
088: * will render:
089: * <pre>
090: * <a href="foo.jsp">Go To Foo</a>
091: * </pre>
092: * </p>
093: * <p>
094: * The AnchorCell tag can also accept NetUI parameter tags that implement the {@link IUrlParams} interface. When
095: * these tags are contained inside of this tag, they add URL parameters onto the rendered href. For example:
096: * <pre>
097: * <netui-data:anchorCell href="foo.jsp" value="Go To Foo">
098: * <netui:parameter name="paramKey" value="paramValue"/>
099: * </netui-data:anchorCell>
100: * </pre>
101: * will render:
102: * <pre>
103: * <a href="foo.jsp?paramKey=paramValue">Go To Foo</a>
104: * </pre>
105: * </p>
106: * <p>
107: * The set of JSP implicit objects available to the body include:
108: * <ul>
109: * <li><code>dataGridModel</code> -- the {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.DataGridTagModel}
110: * for the cell's containing data grid.</li>
111: * <li><code>container</code> -- the {@link org.apache.beehive.netui.script.common.IDataAccessProvider} instance
112: * that exposes the current data item and the current item's index</li>
113: * </ul>
114: * </p>
115: *
116: * @netui:tag name="anchorCell" body-content="scriptless"
117: * description="Renders an HTML table cell inside of a data grid that contains an anchor"
118: */
119: public class AnchorCell extends AbstractHtmlTableCell implements
120: IFormattable, IUrlParams, IHtmlCore, IHtmlEvents, IHtmlI18n {
121:
122: private static final AnchorCellDecorator DECORATOR = new AnchorCellDecorator();
123: private static final String REQUIRED_ATTR = "href, action, linkName";
124: private static final String ANCHOR_FACET_NAME = "anchor";
125:
126: private AnchorCellModel _anchorCellModel = new AnchorCellModel();
127: private AnchorTag.State _anchorState = _anchorCellModel
128: .getAnchorState();
129:
130: /**
131: * The name of this tag; this value is used for error reporting.
132: * @return the String name of this tag
133: */
134: public String getTagName() {
135: return "AnchorCell";
136: }
137:
138: /**
139: * Sets the onClick JavaScript event for the HTML anchor.
140: *
141: * @param onClick the onClick event for the HTML anchor.
142: * @jsptagref.attributedescription The onClick JavaScript event for the HTML anchor.
143: * @jsptagref.attributesyntaxvalue <i>string_onClick</i>
144: * @netui:attribute required="false" rtexprvalue="true" description="The onClick JavaScript event."
145: */
146: public void setOnClick(String onClick) {
147: _anchorState.registerAttribute(
148: AbstractHtmlState.ATTR_JAVASCRIPT,
149: HtmlConstants.ONCLICK, onClick);
150: }
151:
152: /**
153: * Sets the onDblClick JavaScript event for the HTML anchor.
154: *
155: * @param onDblClick the onDblClick event.
156: * @jsptagref.attributedescription The onDblClick JavaScript event for the HTML anchor.
157: * @jsptagref.attributesyntaxvalue <i>string_onDblClick</i>
158: * @netui:attribute required="false" rtexprvalue="true" description="The onDblClick JavaScript event."
159: */
160: public void setOnDblClick(String onDblClick) {
161: _anchorState.registerAttribute(
162: AbstractHtmlState.ATTR_JAVASCRIPT,
163: HtmlConstants.ONDBLCLICK, onDblClick);
164: }
165:
166: /**
167: * Sets the onKeyDown JavaScript event for the HTML anchor.
168: *
169: * @param onKeyDown the onKeyDown event.
170: * @jsptagref.attributedescription The onKeyDown JavaScript event for the HTML anchor.
171: * @jsptagref.attributesyntaxvalue <i>string_onKeyDown</i>
172: * @netui:attribute required="false" rtexprvalue="true" description="The onKeyDown JavaScript event."
173: */
174: public void setOnKeyDown(String onKeyDown) {
175: _anchorState.registerAttribute(
176: AbstractHtmlState.ATTR_JAVASCRIPT,
177: HtmlConstants.ONKEYDOWN, onKeyDown);
178: }
179:
180: /**
181: * Sets the onKeyUp JavaScript event for the HTML anchor.
182: *
183: * @param onKeyUp the onKeyUp event.
184: * @jsptagref.attributedescription The onKeyUp JavaScript event for the HTML anchor.
185: * @jsptagref.attributesyntaxvalue <i>string_onKeyUp</i>
186: * @netui:attribute required="false" rtexprvalue="true" description="The onKeyUp JavaScript event."
187: */
188: public void setOnKeyUp(String onKeyUp) {
189: _anchorState.registerAttribute(
190: AbstractHtmlState.ATTR_JAVASCRIPT,
191: HtmlConstants.ONKEYUP, onKeyUp);
192: }
193:
194: /**
195: * Sets the onKeyPress JavaScript event for the HTML anchor.
196: *
197: * @param onKeyPress the onKeyPress event.
198: * @jsptagref.attributedescription The onKeyPress JavaScript event for the HTML anchor.
199: * @jsptagref.attributesyntaxvalue <i>string_onKeyPress</i>
200: * @netui:attribute required="false" rtexprvalue="true" description="The onKeyPress JavaScript event."
201: */
202: public void setOnKeyPress(String onKeyPress) {
203: _anchorState.registerAttribute(
204: AbstractHtmlState.ATTR_JAVASCRIPT,
205: HtmlConstants.ONKEYPRESS, onKeyPress);
206: }
207:
208: /**
209: * Sets the onMouseDown JavaScript event for the HTML anchor.
210: *
211: * @param onMouseDown the onMouseDown event.
212: * @jsptagref.attributedescription The onMouseDown JavaScript event for the HTML anchor.
213: * @jsptagref.attributesyntaxvalue <i>string_onMouseDown</i>
214: * @netui:attribute required="false" rtexprvalue="true" description="The onMouseDown JavaScript event."
215: */
216: public void setOnMouseDown(String onMouseDown) {
217: _anchorState.registerAttribute(
218: AbstractHtmlState.ATTR_JAVASCRIPT,
219: HtmlConstants.ONMOUSEDOWN, onMouseDown);
220: }
221:
222: /**
223: * Sets the onMouseUp JavaScript event for the HTML anchor.
224: *
225: * @param onMouseUp the onMouseUp event.
226: * @jsptagref.attributedescription The onMouseUp JavaScript event for the HTML anchor.
227: * @jsptagref.attributesyntaxvalue <i>string_onMouseUp</i>
228: * @netui:attribute required="false" rtexprvalue="true" description="The onMouseUp JavaScript event."
229: */
230: public void setOnMouseUp(String onMouseUp) {
231: _anchorState.registerAttribute(
232: AbstractHtmlState.ATTR_JAVASCRIPT,
233: HtmlConstants.ONMOUSEUP, onMouseUp);
234: }
235:
236: /**
237: * Sets the onMouseMove JavaScript event for the HTML anchor.
238: *
239: * @param onMouseMove the onMouseMove event.
240: * @jsptagref.attributedescription The onMouseMove JavaScript event for the HTML anchor.
241: * @jsptagref.attributesyntaxvalue <i>string_onMouseMove</i>
242: * @netui:attribute required="false" rtexprvalue="true" description="The onMouseMove JavaScript event."
243: */
244: public void setOnMouseMove(String onMouseMove) {
245: _anchorState.registerAttribute(
246: AbstractHtmlState.ATTR_JAVASCRIPT,
247: HtmlConstants.ONMOUSEMOVE, onMouseMove);
248: }
249:
250: /**
251: * Sets the onMouseOut JavaScript event for the HTML anchor.
252: *
253: * @param onMouseOut the onMouseOut event.
254: * @jsptagref.attributedescription The onMouseOut JavaScript event for the HTML anchor.
255: * @jsptagref.attributesyntaxvalue <i>string_onMouseOut</i>
256: * @netui:attribute required="false" rtexprvalue="true" description="The onMouseOut JavaScript event."
257: */
258: public void setOnMouseOut(String onMouseOut) {
259: _anchorState.registerAttribute(
260: AbstractHtmlState.ATTR_JAVASCRIPT,
261: HtmlConstants.ONMOUSEOUT, onMouseOut);
262: }
263:
264: /**
265: * Sets the onMouseOver JavaScript event for the HTML anchor.
266: *
267: * @param onMouseOver the onMouseOver event.
268: * @jsptagref.attributedescription The onMouseOver JavaScript event for the HTML anchor.
269: * @jsptagref.attributesyntaxvalue <i>string_onMouseOver</i>
270: * @netui:attribute required="false" rtexprvalue="true" description="The onMouseOver JavaScript event."
271: */
272: public void setOnMouseOver(String onMouseOver) {
273: _anchorState.registerAttribute(
274: AbstractHtmlState.ATTR_JAVASCRIPT,
275: HtmlConstants.ONMOUSEOVER, onMouseOver);
276: }
277:
278: /**
279: * Sets the style of the HTML anchor.
280: *
281: * @param style the style attribute
282: * @jsptagref.attributedescription The style for the HTML anchor.
283: * @jsptagref.attributesyntaxvalue <i>string_style</i>
284: * @netui:attribute required="false" rtexprvalue="true" description="The style for the HTML anchor"
285: */
286: public void setStyle(String style) {
287: if ("".equals(style))
288: return;
289:
290: _anchorState.style = style;
291: }
292:
293: /**
294: * Sets the style class of the HTML anchor.
295: *
296: * @param styleClass the style attribute.
297: * @jsptagref.attributedescription The style class for the HTML anchor.
298: * @jsptagref.attributesyntaxvalue <i>string_style_class</i>
299: * @netui:attribute required="false" rtexprvalue="true" description="The style class for the anchor"
300: */
301: public void setStyleClass(String styleClass) {
302: if ("".equals(styleClass))
303: return;
304:
305: _anchorState.styleClass = styleClass;
306: }
307:
308: /**
309: * Sets the value of the title attribute for the HTML anchor
310: *
311: * @param title the title attribute
312: * @jsptagref.attributedescription The title attribute for the HTML anchor.
313: * @jsptagref.attributesyntaxvalue <i>string_title</i>
314: * @netui:attribute required="false" rtexprvalue="true" description="The title attribute for the anchor"
315: */
316: public void setTitle(String title) {
317: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
318: HtmlConstants.TITLE, title);
319: }
320:
321: /**
322: * Sets <code>charset</code> attribute for the HTML anchor.
323: *
324: * @param charSet the charSet attribute for the HTML anchor.
325: * @jsptagref.attributedescription The charSet attribute for the HTML anchor.
326: * @jsptagref.attributesyntaxvalue <i>string_charset</i>
327: * @netui:attribute required="false" rtexprvalue="true" description="The character set."
328: */
329: public void setCharset(String charSet) {
330: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
331: HtmlConstants.CHARSET, charSet);
332: }
333:
334: /**
335: * Sets <code>type</code> attribute for the HTML anchor.
336: *
337: * @param type the type attribute
338: * @jsptagref.attributedescription The type attribute for the HTML anchor.
339: * @jsptagref.attributesyntaxvalue <i>string_type</i>
340: * @netui:attribute required="false" rtexprvalue="true" description="The attribute for the HTML anchor"
341: */
342: public void setType(String type) {
343: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
344: HtmlConstants.TYPE, type);
345: }
346:
347: /**
348: * Sets <code>hreflang</code> attribute for the anchor.
349: *
350: * @param hreflang the hreflang attribute
351: * @jsptagref.attributedescription The hrefLang attribute for the HTML anchor.
352: * @jsptagref.attributesyntaxvalue <i>string_hreflang</i>
353: * @netui:attribute required="false" rtexprvalue="true" description="The HREF lang attribute for the HTML anchor."
354: */
355: public void setHrefLang(String hreflang) {
356: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
357: HtmlConstants.HREFLANG, hreflang);
358: }
359:
360: /**
361: * Sets <code>rel</code> attribute for the HTML anchor.
362: *
363: * @param rel the rel attribute
364: * @jsptagref.attributedescription The rel attribute for the HTML anchor.
365: * @jsptagref.attributesyntaxvalue <i>string_rel</i>
366: * @netui:attribute required="false" rtexprvalue="true" description="The rel for the HTML anchor."
367: */
368: public void setRel(String rel) {
369: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
370: HtmlConstants.REL, rel);
371: }
372:
373: /**
374: * Sets <code>rev</code> attribute for the HTML anchor.
375: *
376: * @param rev the rev target for the HTML anchor
377: * @jsptagref.attributedescription The rev for the HTML anchor.
378: * @jsptagref.attributesyntaxvalue <i>string_rev</i>
379: * @netui:attribute required="false" rtexprvalue="true" description="The rev for the HTML anchor."
380: */
381: public void setRev(String rev) {
382: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
383: HtmlConstants.REV, rev);
384: }
385:
386: /**
387: * Sets the window target for the HTML anchor.
388: *
389: * @param target the window target for the HTML anchor.
390: * @jsptagref.attributedescription The window target for the HTML anchor.
391: * @jsptagref.attributesyntaxvalue <i>string_target</i>
392: * @netui:attribute required="false" rtexprvalue="true" description="The window target."
393: */
394: public void setTarget(String target) {
395: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
396: HtmlConstants.TARGET, target);
397: }
398:
399: /**
400: * Sets the href of the HTML anchor. This attribute will accept the empty String as a legal value.
401: *
402: * @param href the hyperlink URI for the HTML anchor.
403: * @jsptagref.attributedescription The URL to go to; if the URL needs
404: * parameters, use the parameter tag to get proper encoding of special
405: * characters in the parameters.
406: * @jsptagref.attributesyntaxvalue <i>string_href</i>
407: * @netui:attribute required="false" rtexprvalue="true"
408: * description="The href of the HTML anchor."
409: */
410: public void setHref(String href) {
411: _anchorCellModel.setHref(href);
412: }
413:
414: /**
415: * Set the target "scope" for the anchor's action. Multiple active page flows may exist concurrently within named
416: * scopes. This attribute selects which named scope to use. If omitted, the default scope is assumed.
417: *
418: * @param targetScope the name of the target scope in which the associated action's page flow resides.
419: * @jsptagref.attributedescription The target scope in which the associated action's page flow resides.
420: * @jsptagref.attributesyntaxvalue <i>string_targetScope</i>
421: * @netui:attribute required="false" rtexprvalue="true" description="The target scope in which the associated action's page flow resides"
422: */
423: public void setTargetScope(String targetScope) {
424: _anchorCellModel.setScopeId(targetScope);
425: }
426:
427: /**
428: * The text displayed for the HTML anchor.
429: * @param value the text displayed for the HTML anchor
430: * @jsptagref.attributedescription the text displayed for the HTML anchor
431: * @jsptagref.attributesyntaxvalue <i>string_value</i>
432: * @netui:attribute required="true" rtexprvalue="true"
433: */
434: public void setValue(Object value) {
435: _anchorCellModel.setValue(value);
436: }
437:
438: /**
439: * Set the name of the action for the HTML anchor. The action method must be in the Page Flow with which
440: * the containing JSP is associated.
441: *
442: * @param action the name of the action to set for the Area.
443: * @jsptagref.attributedescription The action method to invoke. The action method must be in Page Flow with which
444: * the containing JSP is associated.
445: * @jsptagref.attributesyntaxvalue <i>string_action</i>
446: * @netui:attribute required="false" rtexprvalue="true"
447: * description="The action method to invoke. The action method must be in the Page Flow with wihch the containing JSP
448: * is associated.
449: */
450: public void setAction(String action) throws JspException {
451: _anchorCellModel.setAction(setRequiredValueAttribute(action,
452: "action"));
453: }
454:
455: /**
456: * Sets the lang attribute for the HTML anchor.
457: * @param lang
458: * @jsptagref.attributedescription The lang attribute for the HTML anchor.
459: * @jsptagref.attributesyntaxvalue <i>string_lang</i>
460: * @netui:attribute required="false" rtexprvalue="true" description="The lang for the HTML anchor."
461: */
462: public void setLang(String lang) {
463: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
464: HtmlConstants.LANG, lang);
465: }
466:
467: /**
468: * Sets the dir attribute for the HTML anchor.
469: * @param dir
470: * @jsptagref.attributedescription The dir attribute for the HTML anchor.
471: * @jsptagref.attributesyntaxvalue <i>string_dir</i>
472: * @netui:attribute required="false" rtexprvalue="true" description="The dir attribute for the HTML anchor."
473: */
474: public void setDir(String dir) {
475: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
476: HtmlConstants.DIR, dir);
477: }
478:
479: /**
480: * Sets the accessKey attribute value. This should key value of the
481: * keyboard navigation key. It is recommended not to use the following
482: * values because there are often used by browsers <code>A, C, E, F, G,
483: * H, V, left arrow, and right arrow</code>.
484: * @param accessKey the accessKey value.
485: * @jsptagref.attributedescription The keyboard navigation key for the element.
486: * The following values are not recommended because they
487: * are often used by browsers: <code>A, C, E, F, G,
488: * H, V, left arrow, and right arrow</code>
489: * @jsptagref.attributesyntaxvalue <i>string_accessKey</i>
490: * @netui:attribute required="false" rtexprvalue="true" type="char"
491: * description=" The keyboard navigation key for the element.
492: * The following values are not recommended because they
493: * are often used by browsers: A, C, E, F, G,
494: * H, V, left arrow, and right arrow."
495: */
496: public void setAccessKey(char accessKey) {
497: if (accessKey == 0x00)
498: return;
499: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
500: HtmlConstants.ACCESSKEY, Character.toString(accessKey));
501: }
502:
503: /**
504: * Sets the tabIndex of the rendered html tag.
505: * @param tabindex the tab index.
506: * @jsptagref.attributedescription The tabIndex of the rendered HTML tag. This attribute determines the position of the
507: * rendered HTML tag in the sequence of tags that the user may advance through by pressing the TAB key.
508: * @jsptagref.attributesyntaxvalue <i>string_tabIndex</i>
509: * @netui:attribute required="false" rtexprvalue="true" type="int"
510: * description="The tabIndex of the rendered HTML tag. This attribute determines the position of the
511: * rendered HTML tag in the sequence of tags that the user may advance through by pressing the TAB key."
512: */
513: public void setTabindex(int tabindex) {
514: _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
515: HtmlConstants.TABINDEX, Integer.toString(tabindex));
516: }
517:
518: /**
519: * Sets the onBlur JavaScript event for the HTML anchor.
520: * @param onblur the onBlur event.
521: * @jsptagref.attributedescription The onBlur JavaScript event for the HTML anchor.
522: * @jsptagref.attributesyntaxvalue <i>string_onBlur</i>
523: * @netui:attribute required="false" rtexprvalue="true"
524: * description="The onBlur JavaScript event."
525: */
526: public void setOnBlur(String onblur) {
527: _anchorState.registerAttribute(
528: AbstractHtmlState.ATTR_JAVASCRIPT,
529: HtmlConstants.ONBLUR, onblur);
530: }
531:
532: /**
533: * Sets the onFocus JavaScript event for the HTML anchor.
534: * @param onfocus the onFocus event.
535: * @jsptagref.attributedescription The onFocus JavaScript event for the HTML anchor.
536: * @jsptagref.attributesyntaxvalue <i>string_onFocus</i>
537: * @netui:attribute required="false" rtexprvalue="true"
538: * description="The onFocus JavaScript event."
539: */
540: public void setOnFocus(String onfocus) {
541: _anchorState.registerAttribute(
542: AbstractHtmlState.ATTR_JAVASCRIPT,
543: HtmlConstants.ONFOCUS, onfocus);
544: }
545:
546: /**
547: * <p>
548: * Set the name of the tagId for the HTML anchor. The provided tagId will have the index of the current
549: * row added as a suffix in order to keep the anchor tagIds unique in the page.
550: * </p>
551: *
552: * @param tagId the the tagId for the HTML anchor.
553: * @jsptagref.attributedescription The tagId.
554: * @jsptagref.attributesyntaxvalue <i>string_tagId</i>
555: * @netui:attribute required="false" rtexprvalue="true"
556: * description="String value. Sets the id (or name) attribute of the rendered HTML tag. "
557: */
558: public void setTagId(String tagId) throws JspException {
559: applyIndexedTagId(_anchorState, tagId);
560: }
561:
562: /**
563: * <p>
564: * Implementation of the {@link org.apache.beehive.netui.tags.IAttributeConsumer} interface. This
565: * allows users of the anchorCell tag to extend the attribute set that is rendered by the HTML
566: * anchor. This method accepts the following facets:
567: * <table>
568: * <tr><td>Facet Name</td><td>Operation</td></tr>
569: * <tr><td><code>anchor</code></td><td>Adds an attribute with the provided <code>name</code> and <code>value</code> to the
570: * attributes rendered on the <a> tag.</td></tr>
571: * </table>
572: * The AnchorCell tag defaults to the setting attributes on the anchor when the facet name is unset.
573: * </p>
574: * @param name the name of the attribute
575: * @param value the value of the attribute
576: * @param facet the facet for the attribute
577: * @throws JspException thrown when the facet is not recognized
578: */
579: public void setAttribute(String name, String value, String facet)
580: throws JspException {
581: if (facet == null || facet.equals(ANCHOR_FACET_NAME))
582: super .addStateAttribute(_anchorState, name, value);
583: else
584: super .setAttribute(name, value, facet);
585: }
586:
587: /**
588: * <p>
589: * Implementation of the {@link IUrlParams} interface. This allows this tag to accept <netui:parameter>
590: * and <netui:parameterMap> in order to add URL parameters onto the rendered anchor. For example:
591: * <pre>
592: * <netui-data:anchorCell href="foo.jsp" value="Go To Foo">
593: * <netui:parameter name="paramKey" value="paramValue"/>
594: * </netui-data:anchorCell>
595: * </pre>
596: * will render an HTML anchor as:
597: * <pre>
598: * <a href="foo.jsp?paramKey=paramValue>Go To Foo</a>
599: * </pre>
600: * </p>
601: * @param name the name of the parameter
602: * @param value the value of the parameter
603: * @param facet the facet for the parameter
604: * @throws JspException thrown when the facet is unsupported
605: */
606: public void addParameter(String name, Object value, String facet)
607: throws JspException {
608: ParamHelper.addParam(_anchorCellModel.getParams(), name, value);
609: }
610:
611: /**
612: * <p>
613: * Interanl method overriding the {@link AbstractHtmlTableCell#applyAttributes()} method
614: * to handle setting attributes on the {@link AnchorCellModel} associated with an instance of this tag.
615: * </p>
616: * @throws JspException when an error occurs applying attributes to the cell model.
617: */
618: protected void applyAttributes() throws JspException {
619: super .applyAttributes();
620:
621: int have = 0;
622: if (_anchorCellModel.getAction() != null)
623: have++;
624: if (_anchorCellModel.getHref() != null)
625: have++;
626: if (_anchorCellModel.getLinkName() != null)
627: have++;
628:
629: /* todo: allow creation of JavaScript anchors */
630: if (have == 0 || have > 1) {
631: String s = Bundle.getString("Tags_Anchor_InvalidAnchorURI",
632: new Object[] { getTagName(), REQUIRED_ATTR });
633: throw new JspException(s);
634: }
635: }
636:
637: /**
638: * Render the contents of the HTML anchor. This method calls to an
639: * {@link org.apache.beehive.netui.databinding.datagrid.api.rendering.CellDecorator} associated with this tag.
640: * The result of renderingi is appended to the <code>appender</code>
641: * @param appender the {@link AbstractRenderAppender} to which output should be rendered
642: * @param jspFragmentOutput the result of having evaluated this tag's {@link javax.servlet.jsp.tagext.JspFragment}
643: */
644: protected void renderDataCellContents(
645: AbstractRenderAppender appender, String jspFragmentOutput) {
646:
647: /* render any JavaScript needed to support framework features */
648: if (_anchorState.id != null) {
649: HttpServletRequest request = JspUtil
650: .getRequest(getJspContext());
651: String script = renderNameAndId(request, _anchorState, null);
652: _anchorCellModel.setJavascript(script);
653: }
654:
655: DECORATOR.decorate(getJspContext(), appender, _anchorCellModel);
656: }
657:
658: /**
659: * Implementation of {@link AbstractHtmlTableCell#internalGetCellModel()} that exposes the {@link AnchorCellModel}
660: * which is storing state for the tag's anchor.
661: * @return this tag's anchor cell model
662: */
663: protected CellModel internalGetCellModel() {
664: return _anchorCellModel;
665: }
666: }
|