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.select;
16:
17: import java.io.Writer;
18: import javax.servlet.jsp.JspException;
19: import org.araneaframework.jsp.tag.uilib.form.BaseFormElementLabelTag;
20: import org.araneaframework.jsp.util.JspUtil;
21: import org.araneaframework.uilib.form.control.SelectControl;
22:
23: /**
24: * Standard form element label tag.
25: *
26: * @author Marko Muts
27: *
28: * @jsp.tag
29: * name = "radioSelectItemLabel"
30: * body-content = "JSP"
31: * description = "Represents localizable label."
32: */
33: public class FormRadioSelectItemLabelHtmlTag extends
34: BaseFormElementLabelTag {
35: protected String value;
36: /** @since 1.1 */
37: protected String radioId;
38:
39: protected int doStartTag(Writer out) throws Exception {
40: super .doStartTag(out);
41:
42: // Type check
43: //XXX: assertControlType("SelectControl");
44:
45: // Prepare
46: SelectControl.ViewModel viewModel = ((SelectControl.ViewModel) controlViewModel);
47:
48: writeLabel(out, viewModel.getLabelForValue(value));
49:
50: return EVAL_BODY_INCLUDE;
51: }
52:
53: /**
54: * @jsp.attribute
55: * type = "java.lang.String"
56: * required = "false"
57: * description = "Select item value."
58: */
59: public void setValue(String value) throws JspException {
60: this .value = (String) evaluateNotNull("value", value,
61: String.class);
62: }
63:
64: /**
65: * @jsp.attribute
66: * type = "java.lang.String"
67: * required = "false"
68: * description = "The HTML id radio button to which this label belongs."
69: * @since 1.1
70: */
71: public void setRadioId(String radioId) throws JspException {
72: this .radioId = (String) evaluate("radioId", radioId,
73: String.class);
74: }
75:
76: /** @since 1.1 */
77: public void writeLabel(Writer out, String label) throws Exception {
78: JspUtil.writeOpenStartTag(out, "span");
79: JspUtil.writeAttribute(out, "class", getStyleClass());
80: JspUtil.writeCloseStartTag_SS(out);
81:
82: JspUtil.writeOpenStartTag(out, "label");
83: JspUtil.writeAttribute(out, "for", radioId);
84: JspUtil.writeCloseStartTag_SS(out);
85: JspUtil.writeEscaped(out, label);
86: JspUtil.writeEndTag_SS(out, "label");
87:
88: JspUtil.writeEndTag(out, "span");
89: }
90: }
|