1 15 package org.apache.tapestry.error; 16 17 import org.apache.hivemind.ApplicationRuntimeException; 18 import org.apache.tapestry.IPage; 19 import org.apache.tapestry.IRequestCycle; 20 import org.apache.tapestry.StaleLinkException; 21 import org.apache.tapestry.services.ResponseRenderer; 22 23 31 public class StaleLinkExceptionPresenterImpl implements StaleLinkExceptionPresenter 32 { 33 private RequestExceptionReporter _requestExceptionReporter; 34 35 private ResponseRenderer _responseRenderer; 36 37 private String _pageName; 38 39 public void presentStaleLinkException(IRequestCycle cycle, StaleLinkException cause) 40 { 41 try 42 { 43 IPage exceptionPage = cycle.getPage(_pageName); 44 45 exceptionPage.setProperty("message", cause.getMessage()); 46 47 cycle.activate(exceptionPage); 48 49 _responseRenderer.renderResponse(cycle); 50 } 51 catch (Throwable ex) 52 { 53 56 _requestExceptionReporter.reportRequestException(ErrorMessages 57 .unableToProcessClientRequest(cause), cause); 58 59 62 _requestExceptionReporter.reportRequestException(ErrorMessages 63 .unableToPresentExceptionPage(ex), ex); 64 65 67 throw new ApplicationRuntimeException(ex.getMessage(), ex); 68 } 69 70 } 71 72 public void setPageName(String pageName) 73 { 74 _pageName = pageName; 75 } 76 77 public void setRequestExceptionReporter(RequestExceptionReporter requestExceptionReporter) 78 { 79 _requestExceptionReporter = requestExceptionReporter; 80 } 81 82 public void setResponseRenderer(ResponseRenderer responseRenderer) 83 { 84 _responseRenderer = responseRenderer; 85 } 86 87 } 88 | Popular Tags |