01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/osp/tags/sakai_2-4-1/jsf/widgets/src/java/org/theospi/jsf/renderer/SplitAreaRenderer.java $
03: * $Id: SplitAreaRenderer.java 15703 2006-10-05 18:16:51Z chmaurer@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.theospi.jsf.renderer;
21:
22: import java.io.IOException;
23:
24: import javax.faces.component.UIComponent;
25: import javax.faces.component.UIOutput;
26: import javax.faces.context.FacesContext;
27: import javax.faces.context.ResponseWriter;
28: import javax.faces.render.Renderer;
29:
30: import org.sakaiproject.jsf.util.RendererUtil;
31: import org.theospi.jsf.util.OspxTagHelper;
32:
33: /**
34: * This creates a split content area. It divides a space in two.
35: * This creates a table of size width x height. It the uses
36: * the divider position to give the first cell a height or width
37: * based on if the direction is vertical or horizontal, respectively.
38: * <br><br>
39: * This class depends on the splitdivider tag to create the actual divide
40: * The second class makes the second cell.
41: *
42: * @author andersjb
43: *
44: */
45:
46: public class SplitAreaRenderer extends Renderer {
47: public boolean supportsComponentType(UIComponent component) {
48: return (component instanceof UIOutput);
49: }
50:
51: /**
52: * This renders html for the beginning of the tag.
53: *
54: * @param context
55: * @param component
56: * @throws IOException
57: */
58: public void encodeBegin(FacesContext context, UIComponent component)
59: throws IOException {
60: ResponseWriter writer = context.getResponseWriter();
61:
62: String directionStr = (String) RendererUtil.getAttribute(
63: context, component, "direction");
64: String width = (String) RendererUtil.getAttribute(context,
65: component, "width");
66: String height = (String) RendererUtil.getAttribute(context,
67: component, "height");
68:
69: //checks for vertical, its abbr., and the y axis
70:
71: writer.write("<table");
72: RendererUtil.writeAttr(writer, "width", width);
73: RendererUtil.writeAttr(writer, "height", height);
74: RendererUtil.writeAttr(writer, "cellspacing", "0");
75: RendererUtil.writeAttr(writer, "cellpadding", "0");
76: writer.write(">");
77:
78: if (!OspxTagHelper.isVertical(directionStr))
79: writer.write("<tr>");
80: }
81:
82: /**
83: * @param context FacesContext for the request we are processing
84: * @param component UIComponent to be rendered
85: * @exception IOException if an input/output error occurs while rendering
86: * @exception NullPointerException if <code>context</code> or <code>component</code> is null
87: */
88: public void encodeEnd(FacesContext context, UIComponent component)
89: throws IOException {
90: String directionStr = (String) RendererUtil.getAttribute(
91: context, component, "direction");
92: ResponseWriter writer = context.getResponseWriter();
93:
94: if (!OspxTagHelper.isVertical(directionStr))
95: writer.write("</tr>");
96:
97: writer.write("</table>");
98: }
99: }
|