Clover coverage report - Code Coverage for tapestry-portlet release 4.0-rc-2
Coverage timestamp: Sat Dec 17 2005 09:45:51 PST
file stats: LOC: 111   Methods: 5
NCLOC: 59   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
PortletRendererImpl.java - 100% 100% 100%
coverage
 1    // Copyright 2005 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.tapestry.portlet;
 16   
 17    import java.io.IOException;
 18    import java.io.PrintWriter;
 19    import java.util.Date;
 20   
 21    import org.apache.tapestry.IMarkupWriter;
 22    import org.apache.tapestry.IPage;
 23    import org.apache.tapestry.IRequestCycle;
 24    import org.apache.tapestry.Tapestry;
 25    import org.apache.tapestry.TapestryUtils;
 26    import org.apache.tapestry.asset.AssetFactory;
 27    import org.apache.tapestry.markup.MarkupWriterSource;
 28    import org.apache.tapestry.util.ContentType;
 29    import org.apache.tapestry.util.PageRenderSupportImpl;
 30    import org.apache.tapestry.web.WebResponse;
 31   
 32    /**
 33    * The guts of rendering a page as a portlet response; used by
 34    * {@link org.apache.tapestry.portlet.RenderService} and
 35    * {@link org.apache.tapestry.portlet.PortletHomeService}.
 36    *
 37    * @author Howard M. Lewis Ship
 38    * @since 4.0
 39    */
 40    public class PortletRendererImpl implements PortletRenderer
 41    {
 42    private WebResponse _response;
 43   
 44    private MarkupWriterSource _markupWriterSource;
 45   
 46    private AssetFactory _assetFactory;
 47   
 48    private String _applicationId;
 49   
 50  1 public void renderPage(IRequestCycle cycle, String pageName) throws IOException
 51    {
 52  1 cycle.activate(pageName);
 53   
 54  1 IPage page = cycle.getPage();
 55   
 56  1 ContentType contentType = page.getResponseContentType();
 57   
 58  1 PrintWriter printWriter = _response.getPrintWriter(contentType);
 59   
 60  1 IMarkupWriter writer = _markupWriterSource.newMarkupWriter(printWriter, contentType);
 61   
 62  1 String namespace = _response.getNamespace();
 63   
 64  1 PageRenderSupportImpl support = new PageRenderSupportImpl(_assetFactory, namespace, null);
 65   
 66  1 TapestryUtils.storePageRenderSupport(cycle, support);
 67   
 68  1 IMarkupWriter nested = writer.getNestedWriter();
 69   
 70  1 cycle.renderPage(nested);
 71   
 72  1 String id = "Tapestry Portlet " + _applicationId + " " + namespace;
 73   
 74  1 writer.comment("BEGIN " + id);
 75  1 writer.comment("Page: " + page.getPageName());
 76  1 writer.comment("Generated: " + new Date());
 77  1 writer.comment("Framework version: " + Tapestry.VERSION);
 78   
 79  1 support.writeBodyScript(writer, cycle);
 80   
 81  1 nested.close();
 82   
 83  1 support.writeInitializationScript(writer);
 84   
 85  1 writer.comment("END " + id);
 86   
 87  1 writer.close();
 88   
 89    // TODO: Trap errors and do some error reporting here?
 90    }
 91   
 92  1 public void setMarkupWriterSource(MarkupWriterSource markupWriterSource)
 93    {
 94  1 _markupWriterSource = markupWriterSource;
 95    }
 96   
 97  1 public void setResponse(WebResponse response)
 98    {
 99  1 _response = response;
 100    }
 101   
 102  1 public void setAssetFactory(AssetFactory assetFactory)
 103    {
 104  1 _assetFactory = assetFactory;
 105    }
 106   
 107  1 public void setApplicationId(String applicationId)
 108    {
 109  1 _applicationId = applicationId;
 110    }
 111    }