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.tag.PresentationTag;
20: import org.araneaframework.jsp.tag.layout.support.CellClassProvider;
21:
22: /**
23: * Layout cell base tag.
24: * @author Taimo Peelo (taimo@araneaframework.org)
25: */
26: public abstract class BaseLayoutCellTag extends PresentationTag {
27: protected boolean overrideLayout = true;
28:
29: /**
30: * HTML id of the cell.
31: * @since 1.1 */
32: protected String id;
33:
34: protected int doStartTag(Writer out) throws Exception {
35: return EVAL_BODY_INCLUDE;
36: }
37:
38: public String getStyleClass() throws JspException {
39: CellClassProvider cellClassProvider = (CellClassProvider) getContextEntry(CellClassProvider.KEY);
40: String result = cellClassProvider != null ? cellClassProvider
41: .getCellClass() : null;
42: result = (result != null && result.length() == 0) ? null
43: : result;
44:
45: String super StyleClass = super .getStyleClass();
46: if (super StyleClass != null) {
47: StringBuffer sb = new StringBuffer(super StyleClass);
48:
49: if (!overrideLayout && result != null)
50: sb.append(' ').append(result);
51:
52: result = sb.toString();
53: }
54: return result;
55: }
56:
57: /* ***********************************************************************************
58: * Tag attributes
59: * ***********************************************************************************/
60:
61: /**
62: * @jsp.attribute
63: * type = "java.lang.String"
64: * required = "false"
65: * description = "Whether cell's styleClass completely overrides styleClass provided by surrounding layout (default behaviour), or is appended to layout's styleClass."
66: */
67: public void setOverrideLayout(String overrideLayout)
68: throws JspException {
69: this .overrideLayout = ((Boolean) evaluate("overrideLayout",
70: overrideLayout, Boolean.class)).booleanValue();
71: }
72:
73: /**
74: * @jsp.attribute
75: * type = "java.lang.String"
76: * required = "false"
77: * description = "HTML id of this row."
78: * @since 1.1
79: */
80: public void setId(String id) throws JspException {
81: this .id = (String) evaluate("id", id, String.class);
82: }
83: }
|