001 // Copyright 2005 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014
015 package org.apache.tapestry.error;
016
017 import java.io.IOException;
018
019 import org.apache.tapestry.IPage;
020 import org.apache.tapestry.IRequestCycle;
021 import org.apache.tapestry.StaleSessionException;
022 import org.apache.tapestry.services.ResponseRenderer;
023
024 /**
025 * Used to activate a particular page to report the
026 * {@link org.apache.tapestry.StaleSessionException}.
027 *
028 * @author Howard M. Lewis Ship
029 * @since 4.0
030 */
031 public class StaleSessionExceptionPresenterImpl implements StaleSessionExceptionPresenter
032 {
033 private ResponseRenderer _responseRenderer;
034
035 private String _pageName;
036
037 public void presentStaleSessionException(IRequestCycle cycle, StaleSessionException cause)
038 throws IOException
039 {
040 IPage exceptionPage = cycle.getPage(_pageName);
041
042 cycle.activate(exceptionPage);
043
044 _responseRenderer.renderResponse(cycle);
045 }
046
047 public void setPageName(String pageName)
048 {
049 _pageName = pageName;
050 }
051
052 public void setResponseRenderer(ResponseRenderer responseRenderer)
053 {
054 _responseRenderer = responseRenderer;
055 }
056
057 }