cedric      2003/03/21 16:25:31

  Modified:    src/share/org/apache/struts/tiles TilesUtilImpl.java
                        TilesUtil.java
               src/share/org/apache/struts/taglib/tiles InsertTag.java
  Log:
  Change the InsertTag to let it use PageContext.include() instead of
  RequestDispatcher.include().
    We are no back to the same mechanism used in the 1.1b3 release.
    This should solves the bug 17562
    Add one entry to TilesUtils and its implementations.
  
  Revision  Changes    Path
  1.3       +22 -4     
jakarta-struts/src/share/org/apache/struts/tiles/TilesUtilImpl.java
  
  Index: TilesUtilImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/TilesUtilImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TilesUtilImpl.java        27 Feb 2003 19:20:50 -0000      1.2
  +++ TilesUtilImpl.java        22 Mar 2003 00:25:30 -0000      1.3
  @@ -69,6 +69,7 @@
   import javax.servlet.ServletRequest;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  +import javax.servlet.jsp.PageContext;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -105,7 +106,8 @@
       /**
        * Do an include using request dispatcher.
        *
  -     * This method is used by the Tiles package anytime an include is required.
  +     * This method is used by the Tiles package when an include is required.
  +     * The Tiles package can use indifferently any form of this method.
        * @param uri Uri or Definition name to forward.
        * @param request Current page request.
        * @param response Current page response.
  @@ -116,6 +118,22 @@
       throws IOException, ServletException
     {
     request.getRequestDispatcher( uri ).include(request, response);
  +  }
  +
  +    /**
  +     * Do an include using PageContext.include().
  +     *
  +     * This method is used by the Tiles package when an include is required.
  +     * The Tiles package can use indifferently any form of this method.
  +     * @param uri Uri or Definition name to forward.
  +     * @param request Current page request.
  +     * @param response Current page response.
  +     * @param servletContext Current servlet context.
  +     */
  +  public static void doInclude(String uri, PageContext pageContext)
  +        throws IOException, ServletException
  +  {
  +  pageContext.include(uri);
     }
   
       /**
  
  
  
  1.6       +22 -4     jakarta-struts/src/share/org/apache/struts/tiles/TilesUtil.java
  
  Index: TilesUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/TilesUtil.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TilesUtil.java    27 Feb 2003 19:20:50 -0000      1.5
  +++ TilesUtil.java    22 Mar 2003 00:25:30 -0000      1.6
  @@ -68,6 +68,7 @@
   import javax.servlet.ServletRequest;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  +import javax.servlet.jsp.PageContext;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -147,7 +148,8 @@
       /**
        * Do an include using request dispatcher.
        *
  -     * This method is used by the Tiles package anytime an include is required.
  +     * This method is used by the Tiles package when an include is required.
  +     * The Tiles package can use indifferently any form of this method.
        * @param uri Uri or Definition name to forward.
        * @param request Current page request.
        * @param response Current page response.
  @@ -158,6 +160,22 @@
           throws IOException, ServletException
     {
     tilesUtilImpl.doInclude(uri, request, response, servletContext);
  +  }
  +
  +    /**
  +     * Do an include using PageContext.include().
  +     *
  +     * This method is used by the Tiles package when an include is required.
  +     * The Tiles package can use indifferently any form of this method.
  +     * @param uri Uri or Definition name to forward.
  +     * @param request Current page request.
  +     * @param response Current page response.
  +     * @param servletContext Current servlet context.
  +     */
  +  public static void doInclude(String uri, PageContext pageContext)
  +        throws IOException, ServletException
  +  {
  +  tilesUtilImpl.doInclude(uri, pageContext);
     }
   
       /**
  
  
  
  1.16      +25 -21    
jakarta-struts/src/share/org/apache/struts/taglib/tiles/InsertTag.java
  
  Index: InsertTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/tiles/InsertTag.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- InsertTag.java    18 Mar 2003 15:04:42 -0000      1.15
  +++ InsertTag.java    22 Mar 2003 00:25:31 -0000      1.16
  @@ -508,7 +508,7 @@
           if (value instanceof AttributeDefinition) {
               // We have a type => return appropriate IncludeType
               return processTypedAttribute((AttributeDefinition) value);
  -            
  +
           } else if (value instanceof ComponentDefinition) {
               return processDefinition((ComponentDefinition) value);
           }
  @@ -566,7 +566,7 @@
                       name,
                       (HttpServletRequest) pageContext.getRequest(),
                       pageContext.getServletContext());
  -                    
  +
               if (definition == null) { // is it possible ?
                   throw new NoSuchDefinitionException();
               }
  @@ -579,7 +579,7 @@
                       + "'. Check if this name exist in definitions factory.");
           } catch (FactoryNotFoundException ex) {
               throw new JspException(ex.getMessage());
  -            
  +
           } catch (DefinitionsFactoryException ex) {
               if (log.isDebugEnabled()) {
                   ex.printStackTrace();
  @@ -737,18 +737,22 @@
           return new InsertHandler((String) value.getValue(), role, getController());
       }
       /**
  -     * Do an include of specified page using pageContext.include()
  -     * This method is used internally to do all includes
  +     * Do an include of specified page.
  +     * This method is used internally to do all includes from this class. It 
delegates
  +     * the include call to the TilesUtil.doInclude().
        * @param page The page that will be included
        * @throws ServletException - Thrown by call to pageContext.include()
        * @throws IOException - Thrown by call to pageContext.include()
        */
       protected void doInclude(String page) throws ServletException, IOException {
  -        TilesUtil.doInclude(
  -            page,
  -            (HttpServletRequest) pageContext.getRequest(),
  -            (HttpServletResponse) pageContext.getResponse(),
  -            pageContext.getServletContext());
  +      /*
  +        TilesUtil.doInclude( page,
  +                        (HttpServletRequest)pageContext.getRequest(),
  +                        (HttpServletResponse)pageContext.getResponse(),
  +                        pageContext.getServletContext());
  +      */
  +      TilesUtil.doInclude( page, pageContext );
  +
       }
   
       /////////////////////////////////////////////////////////////////////////////
  @@ -794,7 +798,7 @@
               String page,
               String role,
               Controller controller) {
  -                
  +
               this.page = page;
               this.role = role;
               this.controller = controller;
  @@ -871,17 +875,17 @@
                   if (flush) {
                       pageContext.getOut().flush();
                   }
  -                
  +
                   // removed if statement for further investigation
                   //if ((page != null) && (page.length() > 0)) {
                       doInclude(page);
                   //}
  -                
  +
               } catch (IOException ex) {
                   processException(
                       ex,
                       "Can't insert page '" + page + "' : " + ex.getMessage());
  -                    
  +
               } catch (IllegalArgumentException ex) { // Can't resolve page uri
                   // Do we ignore bad page uri errors ?
                   if (!(page == null && isErrorIgnored)) {
  @@ -893,7 +897,7 @@
                               + "'. Check if it exists.\n"
                               + ex.getMessage());
                   }
  -                
  +
               } catch (ServletException ex) {
                   Throwable realEx = ex;
                   if (ex.getRootCause() != null) {
  @@ -906,12 +910,12 @@
                           + "] "
                           + realEx.getMessage()
                           + "'");
  -                        
  +
               } catch (Exception ex) {
                   processException(
                       ex,
                       "[Exception in:" + page + "] " + ex.getMessage());
  -                    
  +
               } finally {
                   // restore old context
                   // done only if currentContext not null (bug with Silverstream ?; 
related by Arvindra Sehmi 20010712)
  
  
  

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

Reply via email to