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 015package org.apache.tapestry.error; 016 017import java.io.IOException; 018 019import org.apache.tapestry.IPage; 020import org.apache.tapestry.IRequestCycle; 021import org.apache.tapestry.StaleSessionException; 022import 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 */ 031public 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}