1 package org.apache.turbine.modules.navigations;
2
3
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 */
22
23
24 import org.apache.turbine.annotation.TurbineService;
25 import org.apache.turbine.pipeline.PipelineData;
26 import org.apache.turbine.services.jsp.JspService;
27 import org.apache.turbine.util.RunData;
28
29 /**
30 * Base JSP navigation that should be subclassed by Navigation that want to
31 * use JSP. Subclasses should override the doBuildTemplate() method.
32 *
33 * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
34 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
35 * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
36 * @version $Id$
37 */
38 public class BaseJspNavigation
39 extends TemplateNavigation
40 {
41 /** The prefix for lookup up navigation pages */
42 private static final String prefix = PREFIX + "/";
43
44 /** Injected service instance */
45 @TurbineService
46 private JspService jspService;
47
48 /**
49 * Method to be overridden by subclasses to include data in beans, etc.
50 *
51 * @param pipelineData the PipelineData object
52 * @throws Exception a generic exception.
53 */
54 @Override
55 protected void doBuildTemplate(PipelineData pipelineData)
56 throws Exception
57 {
58 // empty
59 }
60
61 /**
62 * Method that sets up beans and forward the request to the JSP.
63 *
64 * @param pipelineData the PipelineData object
65 * @return null - the JSP sends the information
66 * @throws Exception a generic exception.
67 */
68 @Override
69 public String buildTemplate(PipelineData pipelineData)
70 throws Exception
71 {
72 RunData data = pipelineData.getRunData();
73 // get the name of the JSP we want to use
74 String templateName = data.getTemplateInfo().getNavigationTemplate();
75
76 // navigations are used by a layout
77 jspService.handleRequest(pipelineData, prefix + templateName);
78 return null;
79 }
80 }