1 package org.apache.turbine.modules.layouts; 2 3 4 /* 5 * Licensed to the Apache Software Foundation (ASF) under one 6 * or more contributor license agreements. See the NOTICE file 7 * distributed with this work for additional information 8 * regarding copyright ownership. The ASF licenses this file 9 * to you under the Apache License, Version 2.0 (the 10 * "License"); you may not use this file except in compliance 11 * with the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, 16 * software distributed under the License is distributed on an 17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 * KIND, either express or implied. See the License for the 19 * specific language governing permissions and limitations 20 * under the License. 21 */ 22 23 24 import org.apache.turbine.TurbineConstants; 25 import org.apache.turbine.modules.Layout; 26 import org.apache.turbine.pipeline.PipelineData; 27 import org.apache.turbine.services.jsp.TurbineJsp; 28 import org.apache.turbine.services.jsp.util.JspNavigation; 29 import org.apache.turbine.services.jsp.util.JspScreenPlaceholder; 30 import org.apache.turbine.util.RunData; 31 32 /** 33 * This Layout module allows JSP templates to be used as layouts. Since 34 * dynamic content is supposed to be primarily located in screens and 35 * navigations there should be relatively few reasons to subclass this Layout. 36 * 37 * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a> 38 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a> 39 * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a> 40 */ 41 public class JspLayout 42 extends Layout 43 { 44 /** The prefix for lookup up layout pages */ 45 private String prefix = Layout.PREFIX + "/"; 46 47 /** 48 * Method called by LayoutLoader. 49 * 50 * @deprecated Use PipelineData version instead. 51 * @param data RunData 52 * @throws Exception generic exception 53 */ 54 @Deprecated 55 @Override 56 public void doBuild(RunData data) 57 throws Exception 58 { 59 data.getResponse().setContentType("text/html"); 60 data.declareDirectResponse(); 61 62 // variable to reference the screen in the layout template 63 data.getRequest() 64 .setAttribute(TurbineConstants.SCREEN_PLACEHOLDER, 65 new JspScreenPlaceholder(data)); 66 67 // variable to reference the navigations in the layout template 68 data.getRequest().setAttribute( 69 TurbineConstants.NAVIGATION_PLACEHOLDER, 70 new JspNavigation(data)); 71 72 // Grab the layout template set in the TemplatePage. 73 String templateName = data.getTemplateInfo().getLayoutTemplate(); 74 75 TurbineJsp.handleRequest(data, prefix + templateName, true); 76 } 77 78 /** 79 * Method called by LayoutLoader. 80 * 81 * @param data PipelineData 82 * @throws Exception generic exception 83 */ 84 @Override 85 public void doBuild(PipelineData pipelineData) 86 throws Exception 87 { 88 RunData data = getRunData(pipelineData); 89 data.getResponse().setContentType("text/html"); 90 data.declareDirectResponse(); 91 92 // variable to reference the screen in the layout template 93 data.getRequest() 94 .setAttribute(TurbineConstants.SCREEN_PLACEHOLDER, 95 new JspScreenPlaceholder(data)); 96 97 // variable to reference the navigations in the layout template 98 data.getRequest().setAttribute( 99 TurbineConstants.NAVIGATION_PLACEHOLDER, 100 new JspNavigation(data)); 101 102 // Grab the layout template set in the TemplatePage. 103 String templateName = data.getTemplateInfo().getLayoutTemplate(); 104 105 TurbineJsp.handleRequest(pipelineData, prefix + templateName, true); 106 } 107 108 }