You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jo...@apache.org on 2001/12/08 00:09:04 UTC

cvs commit: jakarta-turbine-3/src/java/org/apache/turbine/pipeline Renderer.java

jon         01/12/07 15:09:04

  Modified:    src/java/org/apache/turbine/pipeline Renderer.java
  Log:
  fixed formatting
  removed unused code
  
  changed one of the render methods to just call Module.handleRequest
  directly since that is the method used in the ClassicPipeline.
  
  screens/Error.vm instead of just Error.vm because the template isn't
  resolved. this is probably bad, but is ok for now.
  
  the result is that this should fix the issues with 'can't find error.vm'
  as well as displaying the right Error.vm...let turbine do it, not this
  class...
  
  -jon
  
  Revision  Changes    Path
  1.5       +22 -32    jakarta-turbine-3/src/java/org/apache/turbine/pipeline/Renderer.java
  
  Index: Renderer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/Renderer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Renderer.java	2001/11/13 19:45:09	1.4
  +++ Renderer.java	2001/12/07 23:09:04	1.5
  @@ -68,52 +68,53 @@
    * @author <a href="mailto:mikeh@apache.org">Mike Haberman</a>
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
    * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
  - * @version $Id: Renderer.java,v 1.4 2001/11/13 19:45:09 mikeh Exp $
  + * @version $Id: Renderer.java,v 1.5 2001/12/07 23:09:04 jon Exp $
    */
   public class Renderer
   {
       public String render(TemplateContext context, String target)
  -        throws TurbineException,Exception
  +        throws TurbineException, Exception
       {
           try
           {
               Log.debug("[ClassicPipeline] render target => " + target);
               return Module.handleRequest(context, target);
           }
  -        catch (Exception e) {
  +        catch (Exception e)
  +        {
               Log.error(e);
  -            return Module.handleRequest(context, "Error.vm");
  +            return Module.handleRequest(context, "screens/Error.vm");
           }
       }
   
  +    /**
  +     * use the resolver to find the template
  +     */
       public String render(String moduleType, RunData data, String template)
           throws TurbineException,Exception
       {
  -        //
  -        // use the resolver to find the template
  -        //
           String target = Turbine.getResolver().getTemplate(moduleType, template);
           return render(data, target);
  -
  -        /*
  -        Turbine.getModuleLoader().getModule(moduleType, template).execute(data);
  -        return Module.handleRequest(Module.getTemplateContext(data),
  -                getFullPath(moduleType, template));
  -        */
       }
   
  +    /**
  +     * This method is called in the ClassicPipeline because it doesn't
  +     * catch exceptions when attempting to render the template. That way,
  +     * exceptions can be caught way up in the Turbine class and the
  +     * error page can be dealt with properly without a lot of extra code
  +     * here.
  +     */
       public String render(RunData data, String target)
  -        throws TurbineException,Exception
  +        throws TurbineException, Exception
       {
  +        Log.debug("[ClassicPipeline] render target => " + target);
           TemplateContext context = Module.getTemplateContext(data);
  -        return render(context, target);
  +        return Module.handleRequest(context, target);
       }
  -
   
  -    public String render(String moduleType, 
  -                         TemplateContext context, 
  +    public String render(String moduleType, TemplateContext context, 
                            String template)
  -        throws TurbineException,Exception
  +        throws TurbineException, Exception
       {
           String target = Turbine.getResolver().getTemplate(moduleType, template);
           return render(context, target);
  @@ -123,10 +124,8 @@
        * Attemps to locate the template and if it can't find it, then
        * it will attempt to render the defaultTemplate
        */
  -    public String render(String moduleType, 
  -                         RunData data, 
  -                         String template, 
  -                         String defaultTemplate)
  +    public String render(String moduleType, RunData data, 
  +                         String template, String defaultTemplate)
           throws TurbineException,Exception
       {
           String target = Turbine.getResolver().getTemplate(moduleType, template);
  @@ -142,13 +141,4 @@
           }
           return output;
       }
  -    
  -    /* 
  -      NO longer needed, use the resolver for this
  -    public String getFullPath(String moduleType, String template)
  -    {
  -        //!! I shouldn't need that slash in there.
  -        return moduleType + '/' + template;
  -    }
  -    */
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>