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.exception.AraneaJspException;
20: import org.araneaframework.jsp.tag.uilib.form.BaseFormElementLabelTag;
21: import org.araneaframework.jsp.tag.uilib.form.FormSimpleLabelHtmlTag;
22: import org.araneaframework.jsp.util.JspUtil;
23: import org.araneaframework.uilib.form.control.MultiSelectControl;
24:
25: /**
26: * Form checkbox label, represents label of one item from
27: * {@link org.araneaframework.uilib.form.control.MultiSelectControl}. It will be rendered with HTML <span> tag.
28: *
29: * @author Marko Muts
30: * @author Jevgeni Kabanov
31: *
32: * @jsp.tag
33: * name = "checkboxMultiSelectItemLabel"
34: * body-content = "JSP"
35: * description = "Represents localizable label."
36: */
37: public class FormCheckboxMultiSelectItemLabelHtmlTag extends
38: BaseFormElementLabelTag {
39: protected String value;
40: protected String checkboxId;
41:
42: protected int doStartTag(Writer out) throws Exception {
43: super .doStartTag(out);
44:
45: // Prepare
46: MultiSelectControl.ViewModel viewModel = ((MultiSelectControl.ViewModel) controlViewModel);
47:
48: if (viewModel.getSelectItemByValue(value) == null)
49: throw new AraneaJspException("Value '" + value
50: + "' not found in values list.");
51:
52: writeLabel(out, viewModel.getSelectItemByValue(value)
53: .getDisplayString());
54: return EVAL_BODY_INCLUDE;
55: }
56:
57: /**
58: * @jsp.attribute
59: * type = "java.lang.String"
60: * required = "false"
61: * description = "Select item value."
62: */
63: public void setValue(String value) throws JspException {
64: this .value = (String) evaluateNotNull("value", value,
65: String.class);
66: }
67:
68: /** @since 1.1 */
69: public void writeLabel(Writer out, String label) throws Exception {
70: JspUtil.writeOpenStartTag(out, "span");
71: JspUtil.writeAttribute(out, "class", getStyleClass());
72: JspUtil.writeCloseStartTag_SS(out);
73:
74: JspUtil.writeOpenStartTag(out, "label");
75: JspUtil.writeAttribute(out, "for", checkboxId);
76: JspUtil.writeCloseStartTag_SS(out);
77: JspUtil.writeEscaped(out, label);
78: JspUtil.writeEndTag_SS(out, "label");
79:
80: JspUtil.writeEndTag(out, "span");
81: }
82:
83: /**
84: * @jsp.attribute
85: * type = "java.lang.String"
86: * required = "false"
87: * description = "The HTML id of checkbox to which this label belongs."
88: * @since 1.1
89: */
90: public void setCheckboxId(String checkboxId) throws JspException {
91: this .checkboxId = (String) evaluate("checkboxId", checkboxId,
92: String.class);
93: }
94: }
|