1 package org.apache.turbine.modules.pages;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 }