You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Vladimir Blagojevic <vl...@borderfree.com> on 2000/07/28 18:07:03 UTC

Small design change of ActionForward

Hi everybody,

I am thinking that maybe it would be better to design ActionForward class as
abstract with an abstract method with this signature:

public abstract void goTo(ActionServlet servlet,
			     HttpServletRequest request,
			     HttpServletResponse response)
			     throws IOException, ServletException

 that subclasses implement.

Subclasses would implement abstract method with something like:

In class ForwardingActionForward :

public void goTo(ActionServlet servlet,
		HttpServletRequest request,
		HttpServletResponse response)
		throws IOException, ServletException{

	 RequestDispatcher rd =
servlet.getServletContext().getRequestDispatcher(this.path);
	 rd.forward(request, response);
 }


and in class RedirectingActionForward :

public void goTo(ActionServlet servlet,
		HttpServletRequest request,
		HttpServletResponse response)
		throws IOException, ServletException{

	response.sendRedirect(this.path);	 

 }

So in ActionServlet in method processActionInstance we can let the dynamic
binding do the work instead of boolean variable "redirected" from
ActionForward class :)

ActionForward forward =  actionInstance.perform(this, mapping, formInstance,
request, response); 
forward.goTo(this,request,response);

I would appreciate your feedback?

Thanks,
Vladimir
 <<actionForward.gif>>