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.display;
16:
17: import java.io.IOException;
18: import java.io.Writer;
19: import org.araneaframework.jsp.exception.AraneaJspException;
20: import org.araneaframework.jsp.tag.uilib.form.BaseFormElementDisplayTag;
21: import org.araneaframework.jsp.util.JspUtil;
22: import org.araneaframework.uilib.form.control.DisplayControl;
23:
24: /**
25: * @author Jevgeni Kabanov (ekabanov <i>at</i> araneaframework <i>dot</i> org)
26: */
27: public abstract class BaseFormListDisplayHtmlTag extends
28: BaseFormElementDisplayTag {
29: protected static final String NEWLINE_SEPARATOR_CODE = "\n";
30:
31: protected String separator = BaseFormListDisplayHtmlTag.NEWLINE_SEPARATOR_CODE;
32: protected DisplayControl.ViewModel displayControlViewModel;
33:
34: protected int doStartTag(Writer out) throws Exception {
35: super .doStartTag(out);
36:
37: assertControlType("DisplayControl");
38:
39: displayControlViewModel = (DisplayControl.ViewModel) controlViewModel;
40:
41: if (getStyleClass() != null) {
42: JspUtil.writeOpenStartTag(out, "span");
43: JspUtil.writeAttribute(out, "class", getStyleClass());
44: JspUtil.writeAttribute(out, "style", getStyle());
45: JspUtil.writeAttributes(out, attributes);
46: JspUtil.writeCloseStartTag(out);
47: }
48:
49: return SKIP_BODY;
50: }
51:
52: protected int doEndTag(Writer out) throws Exception {
53: if (getStyleClass() != null)
54: JspUtil.writeEndTag(out, "span");
55:
56: super .doEndTag(out);
57:
58: return EVAL_PAGE;
59: }
60:
61: /**
62: * @jsp.attribute
63: * type = "java.lang.String"
64: * required = "false"
65: * description = "The separator between list items, can be any string and "\n", meaning a newline (by default "\n")."
66: */
67: public void setSeparator(String separator) {
68: this .separator = separator;
69: }
70:
71: protected void writeSeparator(Writer out) throws IOException,
72: AraneaJspException {
73: if (NEWLINE_SEPARATOR_CODE.equals(separator))
74: JspUtil.writeStartEndTag(out, "br");
75: else
76: JspUtil.writeEscaped(out, separator);
77: }
78: }
|