01: package org.apache.turbine.modules.layouts;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import org.apache.turbine.TurbineConstants;
23: import org.apache.turbine.modules.Layout;
24: import org.apache.turbine.services.jsp.TurbineJsp;
25: import org.apache.turbine.services.jsp.util.JspNavigation;
26: import org.apache.turbine.services.jsp.util.JspScreenPlaceholder;
27: import org.apache.turbine.util.RunData;
28:
29: /**
30: * This Layout module allows JSP templates to be used as layouts. Since
31: * dynamic content is supposed to be primarily located in screens and
32: * navigations there should be relatively few reasons to subclass this Layout.
33: *
34: * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
35: * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
36: * @version $Id: JspLayout.java 534527 2007-05-02 16:10:59Z tv $
37: */
38: public class JspLayout extends Layout {
39: /** The prefix for lookup up layout pages */
40: private String prefix = TurbineConstants.LAYOUT_PREFIX + "/";
41:
42: /**
43: * Method called by LayoutLoader.
44: *
45: * @param data RunData
46: * @throws Exception generic exception
47: */
48: public void doBuild(RunData data) throws Exception {
49: data.getResponse().setContentType("text/html");
50: data.declareDirectResponse();
51:
52: // variable to reference the screen in the layout template
53: data.getRequest().setAttribute(
54: TurbineConstants.SCREEN_PLACEHOLDER,
55: new JspScreenPlaceholder(data));
56:
57: // variable to reference the navigations in the layout template
58: data.getRequest().setAttribute(
59: TurbineConstants.NAVIGATION_PLACEHOLDER,
60: new JspNavigation(data));
61:
62: // Grab the layout template set in the TemplatePage.
63: String templateName = data.getTemplateInfo()
64: .getLayoutTemplate();
65:
66: TurbineJsp.handleRequest(data, prefix + templateName, true);
67: }
68: }
|