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.modules.Navigation;
25  
26  import org.apache.turbine.util.RunData;
27  
28  /***
29   * Base Template Navigation.
30   *
31   * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
32   * @version $Id: TemplateNavigation.java 534527 2007-05-02 16:10:59Z tv $
33   */
34  public abstract class TemplateNavigation
35          extends Navigation
36  {
37      /***
38       * WebMacro Navigations extending this class should overide this
39       * method to perform any particular business logic and add
40       * information to the context.
41       *
42       * @param data Turbine information.
43       * @throws Exception a generic exception.
44       */
45      protected abstract void doBuildTemplate(RunData data)
46              throws Exception;
47  
48      /***
49       * This Builds the WebMacro/FreeMarker/etc template.
50       *
51       * @param data Turbine information.
52       * @return A ConcreteElement.
53       * @throws Exception a generic exception.
54       */
55      public abstract ConcreteElement buildTemplate(RunData data)
56              throws Exception;
57  
58      /***
59       * Calls doBuildTemplate() and then buildTemplate().
60       *
61       * @param data Turbine information.
62       * @return A ConcreteElement.
63       * @throws Exception a generic exception.
64       */
65      protected ConcreteElement doBuild(RunData data)
66              throws Exception
67      {
68          doBuildTemplate(data);
69          return buildTemplate(data);
70      }
71  }