Save This Page
Home » tapestry-src-5.0.19 » org.apache.tapestry5.internal.services » [javadoc | source]
    1   // Copyright 2006, 2007, 2008 The Apache Software Foundation
    2   //
    3   // Licensed under the Apache License, Version 2.0 (the "License");
    4   // you may not use this file except in compliance with the License.
    5   // You may obtain a copy of the License at
    6   //
    7   //     http://www.apache.org/licenses/LICENSE-2.0
    8   //
    9   // Unless required by applicable law or agreed to in writing, software
   10   // distributed under the License is distributed on an "AS IS" BASIS,
   11   // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   12   // See the License for the specific language governing permissions and
   13   // limitations under the License.
   14   
   15   package org.apache.tapestry5.internal.services;
   16   
   17   import org.apache.tapestry5.EventConstants;
   18   import org.apache.tapestry5.internal.structure.Page;
   19   import org.apache.tapestry5.services.ComponentEventResultProcessor;
   20   import org.apache.tapestry5.services.PageRenderRequestHandler;
   21   import org.apache.tapestry5.services.PageRenderRequestParameters;
   22   import org.apache.tapestry5.services.Traditional;
   23   
   24   import java.io.IOException;
   25   
   26   /**
   27    * Handles a PageLink as specified by a PageLinkPathSource by activating and then rendering the page.
   28    */
   29   public class PageRenderRequestHandlerImpl implements PageRenderRequestHandler
   30   {
   31       private final RequestPageCache cache;
   32   
   33       private final ComponentEventResultProcessor resultProcessor;
   34   
   35       private final PageResponseRenderer pageResponseRenderer;
   36   
   37       public PageRenderRequestHandlerImpl(RequestPageCache cache,
   38                                           @Traditional ComponentEventResultProcessor resultProcessor,
   39                                           PageResponseRenderer pageResponseRenderer)
   40       {
   41           this.cache = cache;
   42           this.resultProcessor = resultProcessor;
   43           this.pageResponseRenderer = pageResponseRenderer;
   44       }
   45   
   46       public void handle(PageRenderRequestParameters parameters) throws IOException
   47       {
   48           Page page = cache.get(parameters.getLogicalPageName());
   49   
   50           ComponentResultProcessorWrapper callback = new ComponentResultProcessorWrapper(resultProcessor);
   51   
   52           page.getRootElement().triggerContextEvent(EventConstants.ACTIVATE, parameters.getActivationContext(),
   53                                                     callback);
   54   
   55           // The handler will have asked the result processor to send a response.
   56   
   57           if (callback.isAborted()) return;
   58   
   59           pageResponseRenderer.renderPageResponse(page);
   60       }
   61   }

Save This Page
Home » tapestry-src-5.0.19 » org.apache.tapestry5.internal.services » [javadoc | source]