I think that DispatchAction allows a better separation of code than an Action in which the execute() method contains a if/else branch. I'll no longer need to implement the if/else and I'm letting struts do that.
Regards, Ovidiu ----- Original Message ----- From: "Daniel Joshua" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> Sent: Friday, November 21, 2003 4:27 AM Subject: RE: Simulating multiple inheritance for Action and DispatchAction > Can I branch this of a bit. > > First, do you really need to use a DispatchAction? > > Would it be possible to just use an Action and in the execute() method to do > a branching based on a request parameter. > > Are DispatchActions relly that useful? > > > Regards, > Daniel > > > -----Original Message----- > From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED] > Sent: Thursday, 20 November, 2003 8:11 PM > To: Struts Users Mailing List > Subject: Simulating multiple inheritance for Action and DispatchAction > > > Hi, > In my application I need to have my Actions and my DispatchActions. > Each one of this actions must have the same base class in which I have > common > methods to both of them. > My solution is to first declare an interface IGeneral in which I'm declaring > the > common methods, then create an implementation class,GeneralImpl.Next thind > to do > would be to create my base classes BaseAction and BaseDispatchAction and > this > two must implement IGeneral, and in their implementation they should > delegate to > a private static member of type GeneralImpl, which will handle this methods. > Example: > <code> > public interface IGeneral{ > public Connection getConnection() throws SQLException; > ........... > public User getUser(HttpServletRequest req); > } > </code> > > > Then I'm creating the implementation for this methods: > > > <code> > public class GeneralImpl implements IGeneral{ > private ActionServlet servlet; > public GeneralImpl(ActionServlet srv){ > servlet = srv; > } > public Connection getConnection() throws SQLException{ > //code here > } > ........... > public User getUser(HttpServletRequest req){ > //code here > } > } > </code> > > Now I create the base Actions > > <code> > public abstract class BaseAction extends Action implements IGeneral { > private static GeneralImpl general; > public BaseAction (){ > general = new GeneralImpl(servlet); > } > public ActionForward execute(ActionMapping mapping,ActionForm > form,HttpServletRequest request,HttpServletResponse response){ > return executeAction(ActionMapping mapping,ActionForm > form,HttpServletRequest request,HttpServletResponse response) > } > public abstract executeAction(ActionMapping mapping,ActionForm > form,HttpServletRequest request,HttpServletResponse response); > public Connection getConnection() throws SQLException{ > return general.getConnection(); > } > public User getUser(HttpServletRequest req){ > return general.getUser(req); > } > } > </code> > The same for the DipatchAction. > > The question is anoybody has used something like this ? It this a good thing > to > do it ? > > Tanks in advance and sorry if the text it's too long > Ovidiu > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]