01: package org.apache.turbine.modules.pages;
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.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 extends TemplatePage {
38: /**
39: * Stuffs the Context into the RunData so that it is available to
40: * the Action module and the Screen module via getContext().
41: *
42: * @param data Turbine information.
43: * @exception Exception, a generic exception.
44: */
45: protected void doBuildBeforeAction(RunData data) throws Exception {
46: Context context = TurbineVelocity.getContext(data);
47: data.getTemplateInfo().setTemplateContext(
48: VelocityService.CONTEXT, context);
49: }
50:
51: /**
52: * Allows the VelocityService to peform post-request actions.
53: * (releases the (non-global) tools in the context for reuse later)
54: */
55: protected void doPostBuild(RunData data) throws Exception {
56: Context context = TurbineVelocity.getContext(data);
57: TurbineVelocity.requestFinished(context);
58: }
59: }
|