View Javadoc

1   package org.apache.turbine.modules.navigations;
2   
3   /*
4    * Copyright 2001-2005 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License")
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import org.apache.ecs.ConcreteElement;
20  
21  import org.apache.turbine.modules.Navigation;
22  
23  import org.apache.turbine.util.RunData;
24  
25  /***
26   * Base Template Navigation.
27   *
28   * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
29   * @version $Id: TemplateNavigation.java 264148 2005-08-29 14:21:04Z henning $
30   */
31  public abstract class TemplateNavigation
32          extends Navigation
33  {
34      /***
35       * WebMacro Navigations extending this class should overide this
36       * method to perform any particular business logic and add
37       * information to the context.
38       *
39       * @param data Turbine information.
40       * @throws Exception a generic exception.
41       */
42      protected abstract void doBuildTemplate(RunData data)
43              throws Exception;
44  
45      /***
46       * This Builds the WebMacro/FreeMarker/etc template.
47       *
48       * @param data Turbine information.
49       * @return A ConcreteElement.
50       * @throws Exception a generic exception.
51       */
52      public abstract ConcreteElement buildTemplate(RunData data)
53              throws Exception;
54  
55      /***
56       * Calls doBuildTemplate() and then buildTemplate().
57       *
58       * @param data Turbine information.
59       * @return A ConcreteElement.
60       * @throws Exception a generic exception.
61       */
62      protected ConcreteElement doBuild(RunData data)
63              throws Exception
64      {
65          doBuildTemplate(data);
66          return buildTemplate(data);
67      }
68  }