1 20 package org.enhydra.barracuda.contrib.dbroggisch.page; 21 22 import java.io.IOException ; 23 import javax.servlet.ServletException ; 24 import javax.servlet.http.HttpServletRequest ; 25 import javax.servlet.http.HttpSession ; 26 import org.enhydra.barracuda.core.event.DefaultBaseEventListener; 27 import org.enhydra.barracuda.core.event.EventException; 28 import org.enhydra.barracuda.core.event.ViewEventContext; 29 import org.apache.log4j.Logger; 30 31 32 36 public class RenderPageHandler extends DefaultBaseEventListener { 37 38 private static final Logger logger = Logger.getLogger(RenderPageHandler.class.getName()); 39 40 public void handleViewEvent(ViewEventContext context) 41 throws EventException, ServletException , IOException { 42 HttpServletRequest req = context.getRequest(); 43 HttpSession session = req.getSession(false); 44 45 Page page = null; 46 if (session != null) { 47 page = (Page)session.getAttribute(PageFactory.PAGE_KEY); 48 } 49 if (page == null) { 50 page = (Page)context.getState(PageFactory.PAGE_KEY); 51 } 52 53 if (page != null) { 54 page.render(context); 55 context.getEvent().setHandled(true); 56 } else { 57 logger.error("No page in session, no page in context, allow to fall through to error response event handlers"); 58 } 59 } 60 61 } 62 | Popular Tags |