View Javadoc

1   /*
2    * Copyright 2000-2001,2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.jetspeed.modules.pages;
18  
19  import org.apache.turbine.util.RunData;
20  import org.apache.turbine.services.velocity.TurbineVelocity;
21  import org.apache.turbine.services.velocity.VelocityService;
22  import org.apache.velocity.context.Context;
23  import org.apache.jetspeed.util.template.JetspeedTemplateNavigation;
24  
25  /***
26   * Extends JetspeedTemplatePage to set the Velocity template Context.
27   *
28   * @author <a href="mailto:raphael@apache.org">RaphaŽl Luta</a>
29   * @version $Id: JetspeedVelocityPage.java,v 1.9 2004/02/23 02:59:52 jford Exp $
30   */
31  public class JetspeedVelocityPage extends JetspeedTemplatePage
32  {
33      /***
34       * Stuffs the Context into the RunData so that it is available to
35       * the Action module and the Screen module via getContext().
36       *
37       * Add a couple of default jetspeed context objects.
38       *
39       * @param data Turbine information.
40       * @exception Exception, a generic exception.
41       */
42      protected void doBuildBeforeAction(RunData data) throws Exception
43      {
44          super.doBuildBeforeAction(data);
45  
46          Context context = TurbineVelocity.getContext(data);
47  
48          context.put("jnavigation", new JetspeedTemplateNavigation(data));
49          data.getTemplateInfo().setTemplateContext(VelocityService.CONTEXT, context);
50      }
51  
52      /***
53       * Allows the VelocityService to peform post-request actions.
54       * (releases the (non-global) tools in the context for reuse later)
55       */
56      protected void doPostBuild(RunData data) throws Exception
57      {
58          Context context = TurbineVelocity.getContext(data);
59          TurbineVelocity.requestFinished(context);
60      }
61  
62  }