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.layout;
16:
17: import java.io.Writer;
18: import javax.servlet.jsp.JspException;
19: import org.araneaframework.jsp.util.JspUtil;
20:
21: /**
22: * Aranea's layout tag, allows placing row's and cells inside.
23: * In HTML, this tag corresponds to <table> with <code>class</code> and <code>width</code> attributes.
24: *
25: * @jsp.tag
26: * name = "layout"
27: * body-content = "JSP"
28: * description = "Represents a layout. Layouts allow to describe the way content will be placed on the page."
29: *
30: * @author Taimo Peelo (taimo@araneaframework.org)
31: */
32: public class LayoutHtmlTag extends BaseLayoutTag {
33: protected String width;
34:
35: protected int doStartTag(Writer out) throws Exception {
36: super .doStartTag(out);
37:
38: JspUtil.writeOpenStartTag(out, "table");
39: writeTableAttributes(out);
40: JspUtil.writeCloseStartTag(out);
41:
42: return EVAL_BODY_INCLUDE;
43: }
44:
45: /** Overwrite if other attributes besides <code>styleclass</code> and <code>width</code> are needed for HTML table. */
46: protected void writeTableAttributes(Writer out) throws Exception {
47: addAttribute("style", getStyle());
48: addAttribute("class", getStyleClass());
49: addAttribute("width", width);
50: JspUtil.writeAttributes(out, attributes);
51: }
52:
53: protected int doEndTag(Writer out) throws Exception {
54: JspUtil.writeEndTag(out, "table");
55: return super .doEndTag(out);
56: }
57:
58: /* ***********************************************************************************
59: * Tag attributes
60: * ***********************************************************************************/
61: /**
62: * @jsp.attribute
63: * type = "java.lang.String"
64: * required = "false"
65: * description = "Width of the layout."
66: */
67: public void setWidth(String width) throws JspException {
68: this .width = (String) evaluate("width", width, String.class);
69: }
70: }
|