Re: subclassing action
same Mohan Radhakrishnan wrote: Hi, I am looking for information on subclassing actions. Is there a way to transfer control to the subclass if a certain check in the super action is valid ? Is this how this is done ? In normal OO, it happens based on polymorphism. How is it done with struts ? Thanks, Mohan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: subclassing action
On Mon, 2 Dec 2002, Mohan Radhakrishnan wrote: Date: Mon, 2 Dec 2002 11:51:27 +0530 From: Mohan Radhakrishnan [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: subclassing action Hi, I am looking for information on subclassing actions. Is there a way to transfer control to the subclass if a certain check in the super action is valid ? Is this how this is done ? In normal OO, it happens based on polymorphism. How is it done with struts ? A common technique in Struts based apps is to have a common base Action that embeds functionality common to a set of your application's requirements, such as customized login checking. The general pattern would be to have the common base class implement the public execute() method (in 1.0 it was perform()), and then dispatch to business logic in some other (usually protected) methods defined by the base class. You can also do things like dynamically choose which business logic method to call, based on request parameters. This use case is so common that Struts provides a standard base class (org.apache.struts.actions.DispatchAction) for you. Thanks, Mohan Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: subclassing action
Hi We are using a standard base action but in this case the logic to decide which perform method to call is based on a check in one of the action's perform method. 1. Call Action1 - Show reports the normal way. 2. If reports are to be scheduled , call Action 2. Action2 can be a sub-class of Action1 ? 3. Action2's perform method should be called. Action1 and Action2 differ . So Action2 is a subclass of Action1. Mohan -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Monday, December 02, 2002 10:27 PM To: Struts Users Mailing List Subject: Re: subclassing action On Mon, 2 Dec 2002, Mohan Radhakrishnan wrote: Date: Mon, 2 Dec 2002 11:51:27 +0530 From: Mohan Radhakrishnan [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: subclassing action Hi, I am looking for information on subclassing actions. Is there a way to transfer control to the subclass if a certain check in the super action is valid ? Is this how this is done ? In normal OO, it happens based on polymorphism. How is it done with struts ? A common technique in Struts based apps is to have a common base Action that embeds functionality common to a set of your application's requirements, such as customized login checking. The general pattern would be to have the common base class implement the public execute() method (in 1.0 it was perform()), and then dispatch to business logic in some other (usually protected) methods defined by the base class. You can also do things like dynamically choose which business logic method to call, based on request parameters. This use case is so common that Struts provides a standard base class (org.apache.struts.actions.DispatchAction) for you. Thanks, Mohan Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
subclassing action
Hi, I am looking for information on subclassing actions. Is there a way to transfer control to the subclass if a certain check in the super action is valid ? Is this how this is done ? In normal OO, it happens based on polymorphism. How is it done with struts ? Thanks, Mohan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: subclassing action
Hi, I figured that action mappings can be used to transfer control and the OO stuff should be left to the struts framework. Thanks, Mohan -Original Message- From: Mohan Radhakrishnan [mailto:[EMAIL PROTECTED]] Sent: Monday, December 02, 2002 11:51 AM To: [EMAIL PROTECTED] Subject: subclassing action Hi, I am looking for information on subclassing actions. Is there a way to transfer control to the subclass if a certain check in the super action is valid ? Is this how this is done ? In normal OO, it happens based on polymorphism. How is it done with struts ? Thanks, Mohan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Struts, the Petstore demo, and talking to an EJB tier--I am thinking about subclassing Action to give myself a base class with support for my EJB Session Façade.
Architecture question regarding talking to the EJB tier. The analog of org.apache.struts action, in the Petstore demo, is The interface com.sun.j2ee.blueprints.waf.controller.web.action.HTMLaction. public interface HTMLAction extends java.io.Serializable { public void setServletContext(ServletContext context); public void doStart(HttpServletRequest request); public Event perform(HttpServletRequest request) throws HTMLActionException; public void doEnd(HttpServletRequest request, EventResponse eventResponse); } That Event object is just a value object that gets passed back to the EJB tier by the main servlet, and based on what _kind_ of event it is, a different EJB does the handling. It provides a rather nice Session Facade, as only the main servlet handles sending stuff back in to the EJB tier. Stuff comes back from the EJB Tier through the EventResponse Object, and you can interact witht the oject in the doEnd method. I think this is kind of nice. How do you all feel about subclassing an Action to provide some of the same functionality? Package com.thermopylae.strutsupport.action; Public abstract class MyAction extends org.apache.struts.action { //Generate my value object here. Let my guys subclass it to death. public MyEvent generateEvent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {} //Deal with the response here. Again, let people subclass this public ActionForward doAfter(HttpServletRequest request, HttpServletResponse response, EventResponse eventResponse) {} // They should probably not mess with this though, as it is going to call the two methods above. public final ActionForward perform(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response); MyEvent e = generateEvent(mapping, form, request, response); // include machinery for accessing EJB's via a controller here, in my non-existent processEvent() call. EventResponse r = processEvent(e); return doAfter(request, response, r); } } I would like to get it to the point that only one object knows anything about talking to the EJB tier. This, in conjunction with an EJB controller, would allow me to do this. Please flame on, otherwise I just might do this. -JFD -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]