1 64 65 package com.jcorporate.expresso.core.servlet.viewhandler; 66 67 import com.jcorporate.expresso.core.controller.ControllerException; 68 import com.jcorporate.expresso.core.controller.ControllerResponse; 69 import com.jcorporate.expresso.core.controller.NonHandleableException; 70 import com.jcorporate.expresso.core.jsdkapi.GenericDispatcher; 71 import com.jcorporate.expresso.core.misc.StringUtil; 72 import org.apache.log4j.Logger; 73 74 import javax.servlet.ServletException ; 75 import javax.servlet.http.HttpServletRequest ; 76 import javax.servlet.http.HttpServletResponse ; 77 import java.io.IOException ; 78 import java.util.Vector ; 79 80 81 86 public class JSPViewHandler 87 extends ViewHandler { 88 private static Logger log = Logger.getLogger(JSPViewHandler.class); 89 90 93 public void handleView(ControllerResponse con, HttpServletRequest req, 94 HttpServletResponse res) 95 throws ServletException , IOException , ControllerException, 96 NonHandleableException { 97 if (con.isCustomResponse()) { 98 return; 99 } 100 101 String view = StringUtil.notNull(con.getParameter("view")); 102 103 if (view.equals("")) { 104 view = StringUtil.notNull(con.getParameter("next")); 105 } 106 if (!view.equals("")) { 107 108 109 Vector inputs = con.getInputs(); 110 Vector outputs = con.getOutputs(); 111 Vector actions = con.getTransitions(); 112 Vector blocks = con.getBlocks(); 113 114 if ((inputs == null) && (outputs == null) && (actions == null) && 115 (blocks == null)) { 116 throw new ServletException ("No input, output or " + 117 "actions returned by this Controller"); 118 } 119 } 120 121 123 125 126 127 if (!view.equals("")) { 128 if (log.isDebugEnabled()) { 129 log.debug("Going to 'next/view' URL of '" + view + 130 "' (relative to web-app context root)"); 131 } 132 try { 133 GenericDispatcher.forward(req, res, res.encodeURL(view)); 134 } catch (Exception ee) { 135 log.error("Error forwarding to '" + res.encodeURL(view) + "'", 136 ee); 137 throw new NonHandleableException(ee); 138 } 139 } 140 } 141 142 } | Popular Tags |