1 18 package org.apache.beehive.netui.tags.divpanel; 19 20 import org.apache.beehive.netui.pageflow.interceptor.InterceptorChain; 21 import org.apache.beehive.netui.pageflow.interceptor.InterceptorException; 22 import org.apache.beehive.netui.pageflow.interceptor.request.RequestInterceptorContext; 23 import org.apache.beehive.netui.pageflow.requeststate.INameable; 24 import org.apache.beehive.netui.pageflow.requeststate.NameService; 25 import org.apache.beehive.netui.tags.AbstractClientRequestInterceptor; 26 27 import javax.servlet.http.HttpServletRequest ; 28 29 public class DivPanelCRI extends AbstractClientRequestInterceptor 30 { 31 private static final String SWITCH_PAGE = "switchPage"; 32 33 public void preRequest(RequestInterceptorContext ctxt, InterceptorChain chain) 34 { 35 HttpServletRequest request = ctxt.getRequest(); 36 37 String uri = request.getRequestURI(); 39 String ctxtPath = request.getContextPath(); 40 41 String cmd = getCommand(uri, ctxtPath); 42 43 44 if (SWITCH_PAGE.equals(cmd)) { 46 handlePageSwitch(request); 47 } 48 49 } 50 51 private void handlePageSwitch(HttpServletRequest req) 52 { 53 String dp = req.getParameter("divPanel"); 54 String fp = req.getParameter("firstPage"); 55 57 NameService ns = NameService.instance(req.getSession()); 58 assert(ns != null); 59 60 INameable n = ns.get(dp); 62 if (n == null) { 63 System.err.println("DivPanel '" + dp + "' was not found in the NameService"); 64 return; 65 } 66 if (!(n instanceof DivPanelState)) { 67 System.err.println("Named dp was not an instance of a DivPanelState"); 68 return; 69 } 70 71 DivPanelState state = (DivPanelState) n; 72 state.setFirstPage(fp); 73 } 74 75 public void postRequest(RequestInterceptorContext context, InterceptorChain chain) throws InterceptorException 76 { 77 chain.continueChain(); 78 } 79 } 80 | Popular Tags |