View Javadoc

1   package org.apache.turbine.modules.navigations;
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.ecs.ConcreteElement;
23  
24  import org.apache.turbine.TurbineConstants;
25  
26  import org.apache.turbine.services.jsp.TurbineJsp;
27  
28  import org.apache.turbine.util.RunData;
29  
30  /***
31   * Base JSP navigation that should be subclassed by Navigation that want to
32   * use JSP.  Subclasses should override the doBuildTemplate() method.
33   *
34   * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
35   * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
36   * @version $Id: BaseJspNavigation.java 534527 2007-05-02 16:10:59Z tv $
37   */
38  public class BaseJspNavigation
39          extends TemplateNavigation
40  {
41      /*** The prefix for lookup up navigation pages */
42      private String prefix = TurbineConstants.NAVIGATION_PREFIX + "/";
43  
44      /***
45       * Method to be overidden by subclasses to include data in beans, etc.
46       *
47       * @param data the Rundata object
48       * @throws Exception a generic exception.
49       */
50      protected void doBuildTemplate(RunData data)
51          throws Exception
52      {
53      }
54  
55      /***
56       * Method that sets up beans and forward the request to the JSP.
57       *
58       * @param data the Rundata object
59       * @return null - the JSP sends the information
60       * @throws Exception a generic exception.
61       */
62      public ConcreteElement buildTemplate(RunData data)
63          throws Exception
64      {
65          // get the name of the JSP we want to use
66          String templateName = data.getTemplateInfo().getNavigationTemplate();
67  
68          // navigations are used by a layout
69          TurbineJsp.handleRequest(data, prefix + templateName);
70          return null;
71      }
72  }