01: /**********************************************************************************
02: *
03: * Header:
04: *
05: ***********************************************************************************
06: *
07: * Copyright (c) 2003, 2004 The Sakai Foundation.
08: *
09: * Licensed under the Educational Community License, Version 1.0 (the "License");
10: * you may not use this file except in compliance with the License.
11: * You may obtain a copy of the License at
12: *
13: * http://www.opensource.org/licenses/ecl1.php
14: *
15: * Unless required by applicable law or agreed to in writing, software
16: * distributed under the License is distributed on an "AS IS" BASIS,
17: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18: * See the License for the specific language governing permissions and
19: * limitations under the License.
20: *
21: **********************************************************************************/package org.sakaiproject.jsf.renderer;
22:
23: import java.io.IOException;
24:
25: import javax.faces.component.UIComponent;
26: import javax.faces.component.UIOutput;
27: import javax.faces.context.FacesContext;
28: import javax.faces.context.ResponseWriter;
29: import javax.faces.render.Renderer;
30:
31: import org.sakaiproject.jsf.util.RendererUtil;
32:
33: public class ToolBarMessageRenderer extends Renderer {
34: public boolean supportsComponentType(UIComponent component) {
35: return (component instanceof UIOutput);
36: }
37:
38: public void encodeBegin(FacesContext context, UIComponent component)
39: throws IOException {
40: ResponseWriter writer = context.getResponseWriter();
41: writer.write("<h3>");
42: }
43:
44: /**
45: * @param context FacesContext for the request we are processing
46: * @param component UIComponent to be rendered
47: * @exception IOException if an input/output error occurs while rendering
48: * @exception NullPointerException if <code>context</code> or <code>component</code> is null
49: */
50: public void encodeEnd(FacesContext context, UIComponent component)
51: throws IOException {
52: ResponseWriter writer = context.getResponseWriter();
53:
54: String txt = (String) RendererUtil.getAttribute(context,
55: component, "value");
56: if (txt != null) {
57: writer.write(txt);
58: }
59:
60: writer.write("</h3>");
61: }
62: }
|