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  
20  // Jetspeed classes
21  import org.apache.jetspeed.util.template.JetspeedTemplateNavigation;
22  
23  // Turbine Utility Classes
24  import org.apache.turbine.util.RunData;
25  import org.apache.turbine.services.jsp.JspService;
26  import org.apache.turbine.services.TurbineServices;
27  import org.apache.turbine.services.velocity.VelocityService;
28  import org.apache.turbine.services.velocity.TurbineVelocity;
29  import org.apache.velocity.context.Context;
30  
31  /***
32   * Same as turbine's JspPage, only that it extends JetspeedTemplatePage.
33   * Adds some convenience objects to the request.
34   *
35   * @author <a href="mailto:ingo@raleigh.ibm.com">Ingo Schuster</a>
36   * @version $Revision: 1.7 $      
37   */
38  public class JetspeedJspPage extends JetspeedTemplatePage
39  { 
40  
41      /***
42       * Same method as in turbine's JspPage
43       * Stuffs some useful objects into the request so that 
44       * it is available to the Action module and the Screen module
45       */  
46      protected void doBuildBeforeAction(RunData data) throws Exception
47      {
48          super.doBuildBeforeAction( data);
49          JspService jsp = (JspService)TurbineServices.getInstance()
50              .getService(JspService.SERVICE_NAME);
51                  
52          jsp.addDefaultObjects(data);
53  
54          data.getResponse().setBufferSize(jsp.getDefaultBufferSize());
55  
56          // FIXME: this tools are now in TR.p file, as standard request tools instantiated by turbine.
57          // All tools but jnavigation are there, jnavigation need to be instantiated here
58          // because TemplateNavigation in which depends does have a no args constructor..and
59          // turbine need one to be able to instantiate such class as request tool
60          Context context = TurbineVelocity.getContext(data);
61          TurbineVelocity.getContext(data).put("jnavigation", new JetspeedTemplateNavigation(data));
62          data.getTemplateInfo().setTemplateContext(VelocityService.CONTEXT, context);
63  
64      }
65  
66  }