01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.tags.rendering;
20:
21: import org.apache.beehive.netui.tags.html.HtmlConstants;
22:
23: import java.util.HashMap;
24:
25: abstract public class AreaTag extends TagHtmlBase implements
26: HtmlConstants {
27: /**
28: * Add the Renderer for the HTML and XHTML tokens.
29: * @param html The map of HTML Tag Renderers
30: * @param xhtml The map of XHTML Tag Renderers
31: */
32: public static void add(HashMap html, HashMap htmlQuirks,
33: HashMap xhtml) {
34: html.put(AREA_TAG, new HtmlRendering());
35: htmlQuirks.put(AREA_TAG, new HtmlRendering());
36: xhtml.put(AREA_TAG, new XhtmlRendering());
37: }
38:
39: public void doStartTag(AbstractRenderAppender sb,
40: AbstractTagState renderState) {
41: assert (sb != null) : "Parameter 'sb' must not be null";
42: assert (renderState != null) : "Parameter 'renderState' must not be null";
43: assert (renderState instanceof AnchorTag.State) : "Paramater 'renderState' must be an instance of AnchorTag.State:"
44: + renderState.getClass().getName();
45:
46: AnchorTag.State state = (AnchorTag.State) renderState;
47:
48: renderTag(sb, AREA);
49: renderAttribute(sb, ID, state.id);
50: renderAttribute(sb, NAME, state.name);
51: renderAttribute(sb, HREF, state.href);
52:
53: renderAttribute(sb, CLASS, state.styleClass);
54: renderAttributes(AbstractHtmlState.ATTR_GENERAL, sb, state);
55: renderAttribute(sb, STYLE, state.style);
56:
57: //String onclick = state.getAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONCLICK);
58: //if (onclick != null)
59: // state.removeAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONCLICK);
60: renderAttributes(AbstractHtmlState.ATTR_JAVASCRIPT, sb, state);
61:
62: // backward compat for a second
63: //renderAttributeSingleQuotes(sb, ONCLICK, onclick);
64:
65: writeEnd(sb);
66: }
67:
68: public void doEndTag(AbstractRenderAppender sb) {
69: }
70:
71: abstract protected void writeEnd(AbstractRenderAppender sb);
72:
73: private static class HtmlRendering extends AreaTag {
74: protected void writeEnd(AbstractRenderAppender sb) {
75: sb.append(">");
76: }
77: }
78:
79: private static class XhtmlRendering extends AreaTag {
80: protected void writeEnd(AbstractRenderAppender sb) {
81: sb.append(" />");
82: }
83: }
84: }
|