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: /**
26: * Body, Start Tag: required, End tag: forbidden
27: * Required href
28: */
29: abstract public class InputHiddenTag extends TagHtmlBase implements
30: HtmlConstants {
31: public static void add(HashMap html, HashMap htmlQuirks,
32: HashMap xhtml) {
33: html.put(INPUT_HIDDEN_TAG, new HtmlRendering());
34: htmlQuirks.put(INPUT_HIDDEN_TAG, new HtmlRendering());
35: xhtml.put(INPUT_HIDDEN_TAG, new XhtmlRendering());
36: }
37:
38: public static class State extends AbstractHtmlControlState {
39: public String value;
40:
41: public void clear() {
42: super .clear();
43:
44: value = null;
45: }
46: }
47:
48: public void doStartTag(AbstractRenderAppender sb,
49: AbstractTagState renderState) {
50: assert (sb != null) : "Parameter 'sb' must not be null";
51: assert (renderState != null) : "Parameter 'renderState' must not be null";
52: assert (renderState instanceof State) : "Paramater 'renderState' must be an instance of InputHiddenTag.State";
53:
54: State state = (State) renderState;
55:
56: // Generate an HTML element
57: renderTag(sb, INPUT);
58: renderAttribute(sb, TYPE, INPUT_HIDDEN);
59: renderAttribute(sb, ID, state.id);
60: renderAttribute(sb, NAME, state.name);
61: renderAttribute(sb, VALUE, state.value);
62:
63: renderAttributes(AbstractHtmlState.ATTR_GENERAL, sb, state);
64: renderAttribute(sb, STYLE, state.style);
65: renderAttributes(AbstractHtmlState.ATTR_JAVASCRIPT, sb, state);
66: writeEnd(sb);
67: }
68:
69: public void doEndTag(AbstractRenderAppender sb) {
70: }
71:
72: abstract protected void writeEnd(AbstractRenderAppender sb);
73:
74: private static class HtmlRendering extends InputHiddenTag {
75: protected void writeEnd(AbstractRenderAppender sb) {
76: sb.append(">");
77: }
78: }
79:
80: private static class XhtmlRendering extends InputHiddenTag {
81: protected void writeEnd(AbstractRenderAppender sb) {
82: sb.append(" />");
83: }
84: }
85: }
|