001    package 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    
024    import org.apache.ecs.ConcreteElement;
025    import org.apache.turbine.modules.Navigation;
026    import org.apache.turbine.pipeline.PipelineData;
027    import org.apache.turbine.services.jsp.TurbineJsp;
028    import org.apache.turbine.util.RunData;
029    
030    /**
031     * Base JSP navigation that should be subclassed by Navigation that want to
032     * use JSP.  Subclasses should override the doBuildTemplate() method.
033     *
034     * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
035     * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
036     * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
037     * @version $Id: BaseJspNavigation.java 1078552 2011-03-06 19:58:46Z tv $
038     */
039    public class BaseJspNavigation
040            extends TemplateNavigation
041    {
042        /** The prefix for lookup up navigation pages */
043        private final String prefix = Navigation.PREFIX + "/";
044    
045        /**
046         * Method to be overidden by subclasses to include data in beans, etc.
047         * @deprecated Use PipelineData version instead.
048         * @param data the Rundata object
049         * @throws Exception a generic exception.
050         */
051        @Deprecated
052        @Override
053        protected void doBuildTemplate(RunData data)
054            throws Exception
055        {
056            // empty
057        }
058    
059        /**
060         * Method to be overidden by subclasses to include data in beans, etc.
061         *
062         * @param data the PipelineData object
063         * @throws Exception a generic exception.
064         */
065        @Override
066        protected void doBuildTemplate(PipelineData pipelineData)
067            throws Exception
068        {
069            // empty
070        }
071    
072    
073    
074        /**
075         * Method that sets up beans and forward the request to the JSP.
076         *
077         * @deprecated Use PipelineData version instead.
078         * @param data the Rundata object
079         * @return null - the JSP sends the information
080         * @throws Exception a generic exception.
081         */
082        @Deprecated
083        @Override
084        public ConcreteElement buildTemplate(RunData data)
085            throws Exception
086        {
087            // get the name of the JSP we want to use
088            String templateName = data.getTemplateInfo().getNavigationTemplate();
089    
090            // navigations are used by a layout
091            TurbineJsp.handleRequest(data, prefix + templateName);
092            return null;
093        }
094    
095        /**
096         * Method that sets up beans and forward the request to the JSP.
097         *
098         * @param data the PipelineData object
099         * @return null - the JSP sends the information
100         * @throws Exception a generic exception.
101         */
102        @Override
103        public ConcreteElement buildTemplate(PipelineData pipelineData)
104            throws Exception
105        {
106            RunData data = getRunData(pipelineData);
107            // get the name of the JSP we want to use
108            String templateName = data.getTemplateInfo().getNavigationTemplate();
109    
110            // navigations are used by a layout
111            TurbineJsp.handleRequest(pipelineData, prefix + templateName);
112            return null;
113        }
114    
115    
116    }