1 15 package tutorial.pagetypes; 16 17 import net.sf.tapestry.*; 18 import net.sf.tapestry.engine.SimpleEngine; 19 import net.sf.tapestry.util.prop.OgnlUtils; 20 21 import javax.servlet.ServletException ; 22 23 26 public class PageTypesEngine extends SimpleEngine { 27 private static final String NEW_EXCEPTION_PAGE = "NewException"; 28 29 protected void activateExceptionPage(IRequestCycle cycle, ResponseOutputStream output, Throwable cause) 30 throws ServletException { 31 RequestCycleException cycleE = (RequestCycleException)cause; 32 if (cycleE.getRootCause() instanceof MyException) { 33 handleNewException(cycle, output, cycleE.getRootCause()); 34 } else { 35 super.activateExceptionPage(cycle, output, cause); 36 } 37 } 38 39 46 protected void handleNewException(IRequestCycle cycle, ResponseOutputStream output, Throwable cause) throws ServletException { 47 try { 48 IPage exceptionPage = cycle.getPage(NEW_EXCEPTION_PAGE); 49 OgnlUtils.set("exception", getResourceResolver(), exceptionPage, cause); 50 cycle.setPage(exceptionPage); 51 renderResponse(cycle, output); 52 } catch (Throwable ex) { 53 reportException(Tapestry.getString("AbstractEngine.unable-to-process-client-request"), cause); 56 57 reportException(Tapestry.getString("AbstractEngine.unable-to-present-exception-page"), ex); 60 throw new ServletException (ex.getMessage(), ex); 62 } 63 } 64 } 65 | Popular Tags |