01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.framework;
11:
12: import javax.servlet.http.HttpServletRequest;
13: import java.io.Writer;
14: import java.io.IOException;
15:
16: import org.mmbase.util.logging.Logger;
17: import org.mmbase.util.logging.Logging;
18:
19: /**
20: * Abstract renderer implementation which implements getType and getBlock.
21: *
22: * @author Michiel Meeuwissen
23: * @version $Id: AbstractRenderer.java,v 1.11 2008/02/23 12:15:54 michiel Exp $
24: * @since MMBase-1.9
25: */
26: abstract public class AbstractRenderer implements Renderer {
27:
28: private static final Logger log = Logging
29: .getLoggerInstance(AbstractRenderer.class);
30:
31: protected final Type type;
32: private final Block parent;
33:
34: public AbstractRenderer(Type t, Block p) {
35: type = t;
36: parent = p;
37: }
38:
39: public AbstractRenderer(String t, Block p) {
40: type = Type.valueOf(t);
41: parent = p;
42: }
43:
44: public Type getType() {
45: return type;
46: }
47:
48: public Block getBlock() {
49: return parent;
50: }
51:
52: public java.net.URI getUri() {
53: return null;
54: }
55:
56: protected void decorateIntro(HttpServletRequest request, Writer w,
57: String extraClass) throws IOException {
58: w.write("<div id=\""
59: + request.getAttribute(Framework.COMPONENT_ID_KEY)
60: + "\"");
61: w.write(" class=\"");
62: if (extraClass != null) {
63: w.write(extraClass);
64: w.write(' ');
65: }
66: w.write("mm_c_");
67: w.write(getBlock().getComponent().getName());
68: w.write(" mm_c_b_");
69: w.write(getBlock().getName());
70: w.write(" "
71: + request.getAttribute(Framework.COMPONENT_CLASS_KEY));
72: w.write("\">");
73: }
74:
75: protected void decorateOutro(HttpServletRequest request, Writer w)
76: throws IOException {
77: w.write("</div>");
78: }
79:
80: }
|