View Javadoc

1   package org.apache.turbine.modules.pages;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "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.services.velocity.TurbineVelocity;
23  import org.apache.turbine.services.velocity.VelocityService;
24  
25  import org.apache.turbine.util.RunData;
26  
27  import org.apache.velocity.context.Context;
28  
29  /***
30   * Extends TemplatePage to set the template Context.
31   *
32   * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
33   * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
34   * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
35   * @version $Id: VelocityPage.java 534527 2007-05-02 16:10:59Z tv $
36   */
37  public class VelocityPage
38      extends TemplatePage
39  {
40      /***
41       * Stuffs the Context into the RunData so that it is available to
42       * the Action module and the Screen module via getContext().
43       *
44       * @param data Turbine information.
45       * @exception Exception, a generic exception.
46       */
47      protected void doBuildBeforeAction(RunData data)
48          throws Exception
49      {
50          Context context = TurbineVelocity.getContext(data);
51          data.getTemplateInfo()
52              .setTemplateContext(VelocityService.CONTEXT, context);
53      }
54  
55      /***
56       * Allows the VelocityService to peform post-request actions.
57       * (releases the (non-global) tools in the context for reuse later)
58       */
59      protected void doPostBuild(RunData data)
60          throws Exception
61      {
62          Context context = TurbineVelocity.getContext(data);
63          TurbineVelocity.requestFinished(context);
64      }
65  }