henning     2003/07/22 03:31:40

  Modified:    src/java/org/apache/turbine/modules/navigations
                        VelocityNavigation.java
               src/java/org/apache/turbine/services/template
                        TemplateEngineService.java TemplateService.java
                        TurbineTemplate.java TurbineTemplateService.java
  Log:
  If we want to be able to use navigation templates like foo,Bar.vm, then
  the navigation templates must also be translated by the Template Service.
  
  Added a seventh type of template translations supported by the Template
  Service: navigation templates.
  
  Revision  Changes    Path
  1.5       +5 -4      
jakarta-turbine-2/src/java/org/apache/turbine/modules/navigations/VelocityNavigation.java
  
  Index: VelocityNavigation.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/navigations/VelocityNavigation.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- VelocityNavigation.java   11 Mar 2003 13:55:51 -0000      1.4
  +++ VelocityNavigation.java   22 Jul 2003 10:31:40 -0000      1.5
  @@ -61,9 +61,8 @@
   import org.apache.ecs.StringElement;
   
   import org.apache.turbine.TurbineConstants;
  -
  +import org.apache.turbine.services.template.TurbineTemplate;
   import org.apache.turbine.services.velocity.TurbineVelocity;
  -
   import org.apache.turbine.util.RunData;
   
   import org.apache.velocity.context.Context;
  @@ -130,7 +129,9 @@
       {
           Context context = TurbineVelocity.getContext(data);
   
  -        String templateName = data.getTemplateInfo().getNavigationTemplate();
  +        String navigationTemplate = data.getTemplateInfo().getNavigationTemplate();
  +        String templateName
  +                = TurbineTemplate.getNavigationTemplateName(navigationTemplate);
   
           StringElement output = new StringElement();
           output.setFilterState(false);
  
  
  
  1.6       +2 -1      
jakarta-turbine-2/src/java/org/apache/turbine/services/template/TemplateEngineService.java
  
  Index: TemplateEngineService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/template/TemplateEngineService.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TemplateEngineService.java        9 Mar 2003 03:06:33 -0000       1.5
  +++ TemplateEngineService.java        22 Jul 2003 10:31:40 -0000      1.6
  @@ -75,6 +75,7 @@
       static final String DEFAULT_ERROR_SCREEN = "default.error.screen";
       static final String DEFAULT_LAYOUT_TEMPLATE = "default.layout.template";
       static final String DEFAULT_SCREEN_TEMPLATE = "default.screen.template";
  +    static final String DEFAULT_NAVIGATION_TEMPLATE = "default.navigation.template";
   
       /**
        * Return the configuration of the template engine in
  
  
  
  1.9       +12 -1     
jakarta-turbine-2/src/java/org/apache/turbine/services/template/TemplateService.java
  
  Index: TemplateService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/template/TemplateService.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TemplateService.java      12 Mar 2003 14:29:13 -0000      1.8
  +++ TemplateService.java      22 Jul 2003 10:31:40 -0000      1.9
  @@ -296,6 +296,17 @@
               throws Exception;
   
       /**
  +     * Locate and return the name of the navigation template corresponding
  +     * to the given template name parameter.
  +     *
  +     * @param template The template name parameter.
  +     * @return The found navigation template name.
  +     * @exception Exception, a generic exception.
  +     */
  +    String getNavigationTemplateName(String template)
  +            throws Exception;
  +
  +    /**
        * Translates the supplied template paths into their Turbine-canonical
        * equivalent (probably absolute paths).
        *
  
  
  
  1.9       +14 -1     
jakarta-turbine-2/src/java/org/apache/turbine/services/template/TurbineTemplate.java
  
  Index: TurbineTemplate.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/template/TurbineTemplate.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TurbineTemplate.java      13 Mar 2003 14:46:40 -0000      1.8
  +++ TurbineTemplate.java      22 Jul 2003 10:31:40 -0000      1.9
  @@ -334,6 +334,19 @@
       }
   
       /**
  +     * Locate and return the name of a navigation template.
  +     *
  +     * @param key A String which is the key to the template.
  +     * @return A String with the navigation template path.
  +     * @exception Exception, a generic exception.
  +     */
  +    public static final String getNavigationTemplateName(String key)
  +        throws Exception
  +    {
  +        return getService().getNavigationTemplateName(key);
  +    }
  +
  +    /**
        * Translates the supplied template paths into their Turbine-canonical
        * equivalent (probably absolute paths).
        *
  
  
  
  1.15      +35 -8     
jakarta-turbine-2/src/java/org/apache/turbine/services/template/TurbineTemplateService.java
  
  Index: TurbineTemplateService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/template/TurbineTemplateService.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- TurbineTemplateService.java       15 Jul 2003 15:30:15 -0000      1.14
  +++ TurbineTemplateService.java       22 Jul 2003 10:31:40 -0000      1.15
  @@ -251,8 +251,14 @@
       /** Represents Screen Template Objects */
       public static final String SCREEN_TEMPLATE_NAME = "screen.template";
   
  +    /** Represents Navigation Template Objects */
  +    public static final int NAVIGATION_TEMPLATE_KEY = 6;
  +
  +    /** Represents Navigation Template Objects */
  +    public static final String NAVIGATION_TEMPLATE_NAME = "navigation.template";
  +
       /** Number of different Template Types that we know of */
  -    public static final int TEMPLATE_TYPES = 6;
  +    public static final int TEMPLATE_TYPES = 7;
   
       /** Here we register the mapper objects for our various object types */
       private TemplateMapper [] mapperRegistry = null;
  @@ -606,6 +612,21 @@
       }
   
       /**
  +     * Locate and return the name of the navigation template corresponding
  +     * to the given template name parameter. This might return null if
  +     * the navigation is not found!
  +     *
  +     * @param template The template name parameter.
  +     * @return The found navigation template name.
  +     * @exception Exception, a generic exception.
  +     */
  +    public String getNavigationTemplateName(String template)
  +        throws Exception
  +    {
  +        return ((TemplateMapper) 
mapperRegistry[NAVIGATION_TEMPLATE_KEY]).getMappedName(template);
  +    }
  +
  +    /**
        * Translates the supplied template paths into their Turbine-canonical
        * equivalent (probably absolute paths). This is used if the templating
        * engine (e.g. JSP) does not provide any means to load a page but 
  @@ -707,7 +728,7 @@
   
           String [] mapperNames = new String [] {
               PAGE_NAME,SCREEN_NAME, LAYOUT_NAME,
  -            NAVIGATION_NAME, LAYOUT_TEMPLATE_NAME, SCREEN_TEMPLATE_NAME
  +            NAVIGATION_NAME, LAYOUT_TEMPLATE_NAME, SCREEN_TEMPLATE_NAME, 
NAVIGATION_TEMPLATE_NAME
           };
   
           String [] mapperClasses = new String [] {
  @@ -716,6 +737,7 @@
               TemplateClassMapper.class.getName(),
               TemplateClassMapper.class.getName(),
               TemplateLayoutMapper.class.getName(),
  +            TemplateScreenMapper.class.getName(),
               TemplateScreenMapper.class.getName()
           };
   
  @@ -735,7 +757,10 @@
                       TurbineConstants.LAYOUT_CACHE_SIZE_DEFAULT),
               conf.getInt(
                       TurbineConstants.SCREEN_CACHE_SIZE_KEY,
  -                    TurbineConstants.SCREEN_CACHE_SIZE_DEFAULT)
  +                    TurbineConstants.SCREEN_CACHE_SIZE_DEFAULT),
  +            conf.getInt(
  +                    TurbineConstants.NAVIGATION_CACHE_SIZE_KEY,
  +                    TurbineConstants.NAVIGATION_CACHE_SIZE_DEFAULT)
           };
   
           String [] mapperDefaultProperty = new String [] {
  @@ -744,22 +769,24 @@
               TemplateEngineService.DEFAULT_LAYOUT,
               TemplateEngineService.DEFAULT_NAVIGATION,
               TemplateEngineService.DEFAULT_LAYOUT_TEMPLATE,
  -            TemplateEngineService.DEFAULT_SCREEN_TEMPLATE
  +            TemplateEngineService.DEFAULT_SCREEN_TEMPLATE,
  +            TemplateEngineService.DEFAULT_NAVIGATION_TEMPLATE
           };
   
  -        char [] mapperSeparator = new char [] { '.', '.', '.', '.', '/', '/' };
  +        char [] mapperSeparator = new char [] { '.', '.', '.', '.', '/', '/', '/' };
   
           Loader [] mapperLoader = new Loader [] { 
               null,
               ScreenLoader.getInstance(),
               LayoutLoader.getInstance(),
               NavigationLoader.getInstance(),
  -            null, null, };
  +            null, null, null};
   
           String [] mapperPrefix = new String [] { 
               null, null, null, null,
               TurbineConstants.LAYOUT_PREFIX,
  -            TurbineConstants.SCREEN_PREFIX };
  +            TurbineConstants.SCREEN_PREFIX,
  +            TurbineConstants.NAVIGATION_PREFIX  };
   
           for (int i = 0; i < TEMPLATE_TYPES; i++)
           {
  
  
  

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

Reply via email to