1 package net.sourceforge.formview.struts.action; 2 3 import javax.servlet.ServletContext ; 4 import javax.servlet.http.HttpServletRequest ; 5 import javax.servlet.http.HttpServletResponse ; 6 import net.sourceforge.formview.FormViewConstants; 7 import net.sourceforge.formview.util.WEBFormViewUtil; 8 9 import org.apache.struts.action.ActionForm; 10 import org.apache.struts.action.ActionForward; 11 import org.apache.struts.action.ActionMapping; 12 import org.apache.struts.actions.DispatchAction; 13 14 20 public abstract class FormViewDispatchAction extends DispatchAction { 21 22 23 33 protected ActionForward dispatchMethod(ActionMapping mapping, 34 ActionForm form, HttpServletRequest request, HttpServletResponse response, String name) 35 throws Exception { 36 ActionForward actionForward = super.dispatchMethod(mapping, form, request, response, name); 37 ServletContext context = getServlet().getServletContext(); 40 WEBFormViewUtil.saveFormView(request, context, mapping.getPath()); 41 if (WEBFormViewUtil.isMergeFormViewWithStrutsActionErrors(request)) 42 WEBFormViewUtil.mergeFormViewWithStrutsActionErrors(request, context); 44 return actionForward; 45 } 46 47 57 public ActionForward reload(ActionMapping mapping, ActionForm actionForm, 58 HttpServletRequest request, HttpServletResponse response) 59 throws Exception { 60 return display(mapping, actionForm, request, response); 61 } 62 63 73 public abstract ActionForward display(ActionMapping mapping, 74 ActionForm actionForm, HttpServletRequest request, 75 HttpServletResponse response) throws Exception ; 76 77 88 public final ActionForward loadCreate(ActionMapping mapping, ActionForm form, 89 HttpServletRequest request, HttpServletResponse response) 90 throws Exception { 91 WEBFormViewUtil.saveState(request, getServlet().getServletContext(), FormViewConstants.STATE_CREATE); 93 return load(mapping, form, request, response); 94 } 95 96 107 public final ActionForward loadRead(ActionMapping mapping, ActionForm form, 108 HttpServletRequest request, HttpServletResponse response) 109 throws Exception { 110 WEBFormViewUtil.saveState(request, getServlet().getServletContext(), FormViewConstants.STATE_READ); 112 return load(mapping, form, request, response); 113 } 114 115 126 public final ActionForward loadUpdate(ActionMapping mapping, ActionForm form, 127 HttpServletRequest request, HttpServletResponse response) 128 throws Exception { 129 WEBFormViewUtil.saveState(request, getServlet().getServletContext(), FormViewConstants.STATE_UPDATE); 131 return load(mapping, form, request, response); 132 } 133 134 public abstract ActionForward load(ActionMapping mapping, 135 ActionForm actionForm, HttpServletRequest request, 136 HttpServletResponse response) throws Exception ; 137 } 138 | Popular Tags |