01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: **/package org.araneaframework.jsp.tag.uilib.form.element;
16:
17: import java.io.Writer;
18: import org.araneaframework.jsp.tag.basic.AttributedTagInterface;
19: import org.araneaframework.jsp.tag.uilib.form.BaseFormElementHtmlTag;
20: import org.araneaframework.jsp.util.JspUtil;
21: import org.araneaframework.uilib.form.control.StringArrayRequestControl;
22:
23: /**
24: * Renders concealed {@link org.araneaframework.uilib.form.control.HiddenControl} in an HTML page.
25: *
26: * @author Konstantin Tretyakov
27: *
28: * @jsp.tag
29: * name = "hiddenInput"
30: * body-content = "JSP"
31: * description = "Represents a "hidden" html input element mapped to an UiLib HiddenControl."
32: */
33: public class FormHiddenInputHtmlTag extends BaseFormElementHtmlTag {
34:
35: public FormHiddenInputHtmlTag() {
36: // Hidden element may not be validated!
37: this .validateOnEvent = false;
38: }
39:
40: protected int doStartTag(Writer out) throws Exception {
41: int r = super .doStartTag(out);
42: addContextEntry(AttributedTagInterface.HTML_ELEMENT_KEY, null);
43: return r;
44: }
45:
46: protected int doEndTag(Writer out) throws Exception {
47: // Type check
48: assertControlType("HiddenControl");
49:
50: String name = this .getFullFieldId();
51: StringArrayRequestControl.ViewModel viewModel = ((StringArrayRequestControl.ViewModel) controlViewModel);
52:
53: JspUtil.writeOpenStartTag(out, "input");
54: JspUtil.writeAttribute(out, "name", name);
55: JspUtil.writeAttribute(out, "id", name);
56: JspUtil.writeAttribute(out, "type", "hidden");
57: JspUtil
58: .writeAttribute(out, "value", viewModel
59: .getSimpleValue());
60: JspUtil.writeCloseStartEndTag_SS(out);
61:
62: super.doEndTag(out);
63: return EVAL_PAGE;
64: }
65: }
|