KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tags > rendering > LabelTag


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.rendering;
19
20 import org.apache.beehive.netui.tags.html.HtmlConstants;
21
22 import java.util.HashMap JavaDoc;
23
24 /**
25  * Render the HTML <label> element. In HTML 4.01 the start and end tags are required.
26  */

27 public abstract class LabelTag extends TagHtmlBase
28 {
29     public static void add(HashMap JavaDoc html, HashMap JavaDoc htmlQuirks, HashMap JavaDoc xhtml)
30     {
31         html.put(LABEL_TAG, new Rendering());
32         htmlQuirks.put(LABEL_TAG, new Rendering());
33         xhtml.put(LABEL_TAG, new Rendering());
34     }
35
36     public static class State extends AbstractHtmlState
37     {
38         public String JavaDoc forAttr;
39         public String JavaDoc richDataSource;
40
41         public void clear()
42         {
43             super.clear();
44             forAttr = null;
45             richDataSource = null;
46         }
47     }
48
49     private static class Rendering extends LabelTag implements HtmlConstants
50     {
51         public void doStartTag(AbstractRenderAppender sb, AbstractTagState renderState)
52         {
53             assert(sb != null) : "Parameter 'sb' must not be null";
54             assert(renderState != null) : "Parameter 'renderState' must not be null";
55             assert(renderState instanceof State) : "Paramater 'renderState' must be an instance of LabelTag.State";
56
57             State state = (State) renderState;
58
59
60             renderTag(sb, LABEL);
61             renderAttribute(sb, ID, state.id);
62             renderAttribute(sb, FOR, state.forAttr);
63             renderAttribute(sb, CLASS, state.styleClass);
64
65             renderAttributes(AbstractHtmlState.ATTR_GENERAL, sb, state);
66             renderAttribute(sb, STYLE, state.style);
67             renderAttributes(AbstractHtmlState.ATTR_JAVASCRIPT, sb, state);
68             sb.append(">");
69         }
70
71         public void doEndTag(AbstractRenderAppender sb)
72         {
73             renderEndTag(sb, LABEL);
74         }
75     }
76 }
77
Popular Tags