Clover coverage report - Code Coverage for tapestry release 4.0.1
Coverage timestamp: Fri Mar 31 2006 09:12:14 EST
file stats: LOC: 61   Methods: 3
NCLOC: 28   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
StaleLinkExceptionPresenterImpl.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.error;
 16   
 17    import java.io.IOException;
 18   
 19    import org.apache.hivemind.util.PropertyUtils;
 20    import org.apache.tapestry.IPage;
 21    import org.apache.tapestry.IRequestCycle;
 22    import org.apache.tapestry.StaleLinkException;
 23    import org.apache.tapestry.services.ResponseRenderer;
 24   
 25    /**
 26    * Implementation of {@link org.apache.tapestry.error.StaleLinkExceptionPresenter} that uses a page
 27    * to present the exception. The page must implement a property named "message" of type String and
 28    * should present that message to the user.
 29    *
 30    * @author Howard M. Lewis Ship
 31    * @since 4.0
 32    */
 33    public class StaleLinkExceptionPresenterImpl implements StaleLinkExceptionPresenter
 34    {
 35    private ResponseRenderer _responseRenderer;
 36   
 37    private String _pageName;
 38   
 39  2 public void presentStaleLinkException(IRequestCycle cycle, StaleLinkException cause)
 40    throws IOException
 41    {
 42  2 IPage exceptionPage = cycle.getPage(_pageName);
 43   
 44  2 PropertyUtils.write(exceptionPage, "message", cause.getMessage());
 45   
 46  2 cycle.activate(exceptionPage);
 47   
 48  2 _responseRenderer.renderResponse(cycle);
 49    }
 50   
 51  2 public void setPageName(String pageName)
 52    {
 53  2 _pageName = pageName;
 54    }
 55   
 56  2 public void setResponseRenderer(ResponseRenderer responseRenderer)
 57    {
 58  2 _responseRenderer = responseRenderer;
 59    }
 60   
 61    }