01: /*
02: * $Id: Content.java,v 1.2 2003/09/14 05:36:48 jonesde Exp $
03: *
04: * Copyright (c) 2001-2003 Sun Microsystems Inc., published in "Advanced Java Server Pages" by Prentice Hall PTR
05: * Copyright (c) 2002 The Open For Business Project - www.ofbiz.org
06: *
07: * Permission is hereby granted, free of charge, to any person obtaining a
08: * copy of this software and associated documentation files (the "Software"),
09: * to deal in the Software without restriction, including without limitation
10: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11: * and/or sell copies of the Software, and to permit persons to whom the
12: * Software is furnished to do so, subject to the following conditions:
13: *
14: * The above copyright notice and this permission notice shall be included
15: * in all copies or substantial portions of the Software.
16: *
17: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18: * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21: * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
22: * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
23: * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24: *
25: */
26: package org.ofbiz.content.webapp.region;
27:
28: import javax.servlet.ServletException;
29: import javax.servlet.http.HttpServletRequest;
30: import javax.servlet.http.HttpServletResponse;
31: import javax.servlet.jsp.JspException;
32: import javax.servlet.jsp.PageContext;
33:
34: /**
35: * Abstract base class for Section and Region
36: * <br>Subclasses of Content must implement render(PageContext)
37: *
38: *@author David M. Geary in the book "Advanced Java Server Pages"
39: *@author <a href="mailto:jonesde@ofbiz.org">David E. Jones</a>
40: *@created February 26, 2002
41: *@version 1.0
42: */
43: public abstract class Content implements java.io.Serializable {
44: protected final String content;
45:
46: /** type can be:
47: * <br>- direct (for direct inline content)
48: * <br>- region (for a nested region)
49: * <br>- default (for region if matches region name OR JSP/Servlet resource otherwise)
50: * <br>- resource (for JSP/Servlet resource)
51: * <br>- or any ViewHandler defined in the corresponding controller.xml file
52: */
53: protected final String type;
54:
55: // Render this content in a JSP page
56: abstract void render(PageContext pc) throws JspException;
57:
58: abstract void render(HttpServletRequest request,
59: HttpServletResponse response) throws java.io.IOException,
60: ServletException;
61:
62: public Content(String content, String type) {
63: this .content = content;
64: this .type = type;
65: }
66:
67: public String getContent() {
68: return content;
69: }
70:
71: public String getType() {
72: return type;
73: }
74:
75: public String toString() {
76: return "Content: " + content + ", type: " + type;
77: }
78: }
|