001package org.apache.turbine.modules.layouts;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.turbine.TurbineConstants;
023import org.apache.turbine.pipeline.PipelineData;
024import org.apache.turbine.util.template.TemplateNavigation;
025import org.apache.turbine.util.template.TemplateScreen;
026import org.apache.velocity.context.Context;
027
028/**
029 * This Layout module allows Velocity templates
030 * to be used as layouts. It will stream directly the output of
031 * the layout and navigation templates to the output writer without
032 * using a screen. Use this if you have a large page to output
033 * and won't buffer it in the memory.
034 *
035 * @author <a href="mailto:raphael@apache.org">Raphaƫl Luta</a>
036 * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
037 * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
038 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
039 * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
040 * @version $Id$
041 */
042public class VelocityDirectLayout extends VelocityLayout
043{
044    /**
045     * @see org.apache.turbine.modules.layouts.VelocityLayout#populateContext(org.apache.turbine.pipeline.PipelineData, org.apache.velocity.context.Context)
046     */
047    @Override
048    protected void populateContext(PipelineData pipelineData, Context context) throws Exception
049    {
050        // variable for the screen in the layout template
051        context.put(TurbineConstants.SCREEN_PLACEHOLDER,
052                    new TemplateScreen(pipelineData));
053
054        // variable to reference the navigation screen in the layout template
055        context.put(TurbineConstants.NAVIGATION_PLACEHOLDER,
056                    new TemplateNavigation(pipelineData));
057    }
058}