Coverage Report - org.apache.tapestry.services.impl.DojoAjaxResponseContributorImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
DojoAjaxResponseContributorImpl
0%
0/28
0%
0/6
1.273
 
 1  
 // Copyright May 8, 2006 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  
 package org.apache.tapestry.services.impl;
 15  
 
 16  
 import org.apache.tapestry.IRequestCycle;
 17  
 import org.apache.tapestry.asset.AssetFactory;
 18  
 import org.apache.tapestry.engine.IEngineService;
 19  
 import org.apache.tapestry.markup.MarkupWriterSource;
 20  
 import org.apache.tapestry.services.RequestLocaleManager;
 21  
 import org.apache.tapestry.services.ResponseBuilder;
 22  
 import org.apache.tapestry.services.ResponseContributor;
 23  
 import org.apache.tapestry.web.WebRequest;
 24  
 import org.apache.tapestry.web.WebResponse;
 25  
 
 26  
 import java.io.IOException;
 27  
 import java.util.ArrayList;
 28  
 import java.util.List;
 29  
 
 30  
 
 31  
 /**
 32  
  * Handles determining dojo ajax requests.
 33  
  * 
 34  
  * @author jkuhnert
 35  
  */
 36  0
 public class DojoAjaxResponseContributorImpl implements ResponseContributor
 37  
 {
 38  
     public static final String DOJO_AJAX_HEADER = "dojo-ajax-request";
 39  
     
 40  
     private RequestLocaleManager _localeManager;
 41  
     
 42  
     private MarkupWriterSource _markupWriterSource;
 43  
     
 44  
     private WebResponse _webResponse;
 45  
     
 46  
     private WebRequest _webRequest;
 47  
     
 48  
     private String _exceptionPageName;
 49  
     
 50  
     private String _staleSessionPageName;
 51  
     
 52  
     private String _staleLinkPageName;
 53  
     
 54  
     private AssetFactory _assetFactory;
 55  
     
 56  
     private IEngineService _pageService;
 57  
     
 58  
     /** 
 59  
      * {@inheritDoc}
 60  
      */
 61  
     public ResponseBuilder createBuilder(IRequestCycle cycle)
 62  
         throws IOException
 63  
     {
 64  0
         List errorPages = new ArrayList();
 65  0
         errorPages.add(_exceptionPageName);
 66  0
         errorPages.add(_staleSessionPageName);
 67  0
         errorPages.add(_staleLinkPageName);
 68  
         
 69  0
         return new DojoAjaxResponseBuilder(cycle, _localeManager, 
 70  
                 _markupWriterSource,
 71  
                 _webResponse, errorPages, _assetFactory, 
 72  
                 _webResponse.getNamespace(), _pageService);
 73  
     }
 74  
     
 75  
     /** 
 76  
      * {@inheritDoc}
 77  
      */
 78  
     public boolean handlesResponse(IRequestCycle cycle)
 79  
     {
 80  0
         String parm = cycle.getParameter(DOJO_AJAX_HEADER);
 81  
         
 82  0
         if (parm != null && Boolean.valueOf(parm).booleanValue())
 83  0
             return true;
 84  0
         return _webRequest.getHeader(DOJO_AJAX_HEADER) != null;
 85  
     }
 86  
     
 87  
     public void setLocaleManager(RequestLocaleManager localeManager)
 88  
     {
 89  0
         _localeManager = localeManager;
 90  0
     }
 91  
     
 92  
     public void setMarkupWriterSource(MarkupWriterSource markupWriterSource)
 93  
     {
 94  0
         _markupWriterSource = markupWriterSource;
 95  0
     }
 96  
     
 97  
     public void setWebResponse(WebResponse webResponse)
 98  
     {
 99  0
         _webResponse = webResponse;
 100  0
     }
 101  
     
 102  
     public void setWebRequest(WebRequest webRequest)
 103  
     {
 104  0
         _webRequest  = webRequest;
 105  0
     }
 106  
     
 107  
     public void setExceptionPageName(String name)
 108  
     {
 109  0
         _exceptionPageName = name;
 110  0
     }
 111  
     
 112  
     public void setStaleSessionPageName(String name)
 113  
     {
 114  0
         _staleSessionPageName = name;
 115  0
     }
 116  
     
 117  
     public void setStaleLinkPageName(String name)
 118  
     {
 119  0
         _staleLinkPageName = name;
 120  0
     }
 121  
     
 122  
     public void setAssetFactory(AssetFactory factory)
 123  
     {
 124  0
         _assetFactory = factory;
 125  0
     }
 126  
     
 127  
     public void setPageService(IEngineService service)
 128  
     {
 129  0
         _pageService = service;
 130  0
     }
 131  
 }