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.example.common.tags.example.component;
16:
17: import java.io.Writer;
18: import javax.servlet.jsp.JspException;
19: import org.araneaframework.jsp.tag.PresentationTag;
20: import org.araneaframework.jsp.util.JspUtil;
21:
22: /**
23: * @author Taimo Peelo (taimo@araneaframework.org)
24: * @jsp.tag
25: * name = "component"
26: * body-content = "JSP"
27: */
28: public class ComponentTag extends PresentationTag {
29: public final static String KEY = "example.component.key";
30: public final static String DEFAULT_COMPONENT_STYLE = "component";
31: public final static String DEFAULT_COMPONENT_WIDTH_STYLE = "w100p";
32:
33: protected String widthClass;
34:
35: public ComponentTag() {
36: styleClass = ComponentTag.DEFAULT_COMPONENT_STYLE;
37: widthClass = ComponentTag.DEFAULT_COMPONENT_WIDTH_STYLE;
38: }
39:
40: protected int doStartTag(Writer out) throws Exception {
41: super .doStartTag(out);
42:
43: addContextEntry(ComponentTag.KEY, this );
44:
45: JspUtil.writeOpenStartTag(out, "div");
46: JspUtil.writeAttribute(out, "class", getStyleClass());
47: JspUtil.writeAttribute(out, "style", getStyle());
48: JspUtil.writeCloseStartTag(out);
49:
50: // second div... maybe should be moved out
51: JspUtil.writeOpenStartTag(out, "div");
52: JspUtil.writeAttribute(out, "class", widthClass);
53: JspUtil.writeCloseStartTag(out);
54:
55: return EVAL_BODY_INCLUDE;
56: }
57:
58: protected int doEndTag(Writer out) throws Exception {
59: JspUtil.writeEndTag(out, "div");
60: JspUtil.writeEndTag(out, "div");
61: super .doEndTag(out);
62: return EVAL_PAGE;
63: }
64:
65: /**
66: * @jsp.attribute
67: * type = "java.lang.String"
68: * required = "false"
69: * description = "CSS class for secondary DIV that is written out by this tag.
70: * By default this is w100p - maximum component width is set."
71: */
72: public void setWidthClass(String widthClass) throws JspException {
73: this .widthClass = (String) evaluate("widthClass", widthClass,
74: String.class);
75: }
76: }
|