mikeh       01/07/05 15:05:26

  Modified:    src/java/org/apache/turbine/modules/screens
                        VelocityScreen.java
  Log:
  pulled out some common code.  Will make it easier, if we want
  the "screens" prepended to template name.
  
  Revision  Changes    Path
  1.16      +19 -19    
jakarta-turbine/src/java/org/apache/turbine/modules/screens/VelocityScreen.java
  
  Index: VelocityScreen.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/modules/screens/VelocityScreen.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- VelocityScreen.java       2001/07/05 21:55:49     1.15
  +++ VelocityScreen.java       2001/07/05 22:05:24     1.16
  @@ -79,7 +79,7 @@
    * class and override the doBuildTemplate() method.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Dave Bryson</a>
  - * @version $Id: VelocityScreen.java,v 1.15 2001/07/05 21:55:49 mikeh Exp $
  + * @version $Id: VelocityScreen.java,v 1.16 2001/07/05 22:05:24 mikeh Exp $
    */
   public class VelocityScreen extends TemplateScreen
   {
  @@ -113,6 +113,20 @@
       }
   
       /**
  +     * normalized the template name 
  +     * Template service adds the leading slash, but make it sure.
  +     */
  +    protected String normalizeTemplateName(String templateName)
  +    {
  +        if ((templateName.length() > 0) && (templateName.charAt(0) != '/'))
  +        {
  +            templateName = '/' + templateName;
  +        }
  +        templateName =  TurbineConstants.SCREENS + templateName;
  +        return templateName;
  +    }
  +
  +    /**
        * This builds the Velocity template.
        *
        * @param data Turbine information.
  @@ -130,14 +144,7 @@
           String templateName = TurbineTemplate.getScreenTemplateName(
               data.getTemplateInfo().getScreenTemplate() );
   
  -        // Template service adds the leading slash, but make it sure.
  -        if ((templateName.length() > 0) &&
  -            (templateName.charAt(0) != '/'))
  -        {
  -            templateName = '/' + templateName;
  -        }
  -
  -        templateName =  TurbineConstants.SCREENS + templateName;
  +        templateName = normalizeTemplateName(templateName);
           try
           {
               // if a layout has been defined return the results, otherwise
  @@ -160,16 +167,9 @@
               // directory.
               context.put ( "processingException", e.toString() );
               context.put ( "stackTrace", StringUtils.stackTrace(e) );
  -            templateName = TurbineResources.getString(
  -                "template.error", "/error.vm");
  -
  -            if ((templateName.length() > 0) &&
  -                (templateName.charAt(0) != '/'))
  -            {
  -                templateName = '/' + templateName;
  -            }
  -
  -            templateName =  TurbineConstants.SCREENS + templateName;
  +            templateName = TurbineResources.getString("template.error", 
  +                                                      "/error.vm");
  +            templateName = normalizeTemplateName(templateName);
               screenData = TurbineVelocity.handleRequest(context, templateName);
           }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to