001package org.apache.turbine.modules.navigations; 002 003 004/* 005 * Licensed to the Apache Software Foundation (ASF) under one 006 * or more contributor license agreements. See the NOTICE file 007 * distributed with this work for additional information 008 * regarding copyright ownership. The ASF licenses this file 009 * to you under the Apache License, Version 2.0 (the 010 * "License"); you may not use this file except in compliance 011 * with the License. You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, 016 * software distributed under the License is distributed on an 017 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 018 * KIND, either express or implied. See the License for the 019 * specific language governing permissions and limitations 020 * under the License. 021 */ 022 023 024import org.apache.turbine.annotation.TurbineService; 025import org.apache.turbine.pipeline.PipelineData; 026import org.apache.turbine.services.jsp.JspService; 027import org.apache.turbine.util.RunData; 028 029/** 030 * Base JSP navigation that should be subclassed by Navigation that want to 031 * use JSP. Subclasses should override the doBuildTemplate() method. 032 * 033 * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a> 034 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a> 035 * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a> 036 * @version $Id$ 037 */ 038public class BaseJspNavigation 039 extends TemplateNavigation 040{ 041 /** The prefix for lookup up navigation pages */ 042 private static final String prefix = PREFIX + "/"; 043 044 /** Injected service instance */ 045 @TurbineService 046 private JspService jspService; 047 048 /** 049 * Method to be overridden by subclasses to include data in beans, etc. 050 * 051 * @param pipelineData the PipelineData object 052 * @throws Exception a generic exception. 053 */ 054 @Override 055 protected void doBuildTemplate(PipelineData pipelineData) 056 throws Exception 057 { 058 // empty 059 } 060 061 /** 062 * Method that sets up beans and forward the request to the JSP. 063 * 064 * @param pipelineData the PipelineData object 065 * @return null - the JSP sends the information 066 * @throws Exception a generic exception. 067 */ 068 @Override 069 public String buildTemplate(PipelineData pipelineData) 070 throws Exception 071 { 072 RunData data = pipelineData.getRunData(); 073 // get the name of the JSP we want to use 074 String templateName = data.getTemplateInfo().getNavigationTemplate(); 075 076 // navigations are used by a layout 077 jspService.handleRequest(pipelineData, prefix + templateName); 078 return null; 079 } 080}