Re: abstract class

2002-12-05 Thread V. Cekvenich
From basicPortal, using disptaching (it also uses event object to 
encsulate response,request, forward, formbean, etc.):

protected Object dispatchEvents(ActionEvent ae) {
String parm = ae.getReq().getParameter(DISPATCH_KEY);
if (parm == null)
parm = "Default";

// start Dispatching
ActionForward retObj = new ActionForward();
try {


			String methodName = "on" + parm + "Exec";
			
			try {
Class args[] = { 
Class.forName("org.apache.commons.dispatch.ActionEvent") };
Method eventMethod = this.getClass().getMethod(methodName, args);

Object objs[] = { ae };
retObj = (ActionForward)eventMethod.invoke(this, objs);
			}
			catch(NoSuchMethodException e) {
System.out.println("Could not find method " + methodName + 
"(ActionEvent) to invoke.");
			}
			catch(Exception e) {
e.printStackTrace();
			}



} catch (Exception e) {
log(e, this, "*** DISPATCHING a " + e.toString());
}

return (ActionForward) retObj;
}


Mohan Radhakrishnan wrote:
Hi,
   I looked at the archives and found abstract base actions.

   1. I have two actions, the base handling the basic flow and the
sub-action handling the alternate flow. ( Apart from these two I have a
common base action which all actions extend containing login checks etc. )

   Now I wanted to pass the control to the sub-action when the alternate
flow happens. Usually it is polymorphism. Now with struts everything is
routed by the config.xml file. I can't call a method in the sub-action from
the base action ? Does it violate the struts flow ?

   That is why I decided to use an abstract method somewhere in the
hierarchy to be polymorphic but abstract classes can't be instantiated by
struts.

   That is what caused the confusion. Is my thinking right ?

The reason why I decided to have a sub-action instead of a helper class is
that in some cases it might be an independent action.

Thanks,
Mohan 

-Original Message-
From: Brian Hickey [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 04, 2002 5:56 PM
To: Struts Users Mailing List
Subject: Re: abstract class


Mohan,

Two different behaviors is what you wish then you need to derive from a
concrete base class. Abstract classes are more likely to provide conformance
to an architecture or signature template.

In Struts, folks usually inherit from the Action class to create certain
behaviors. If you need to super() to a base class, you are correct, it
cannot be an abstract class. I would suggest that it shouldn't be in most
any case, but I don't know your architecture.

It is also early and I am not sure of your terminology. A base class is a
super class (standard inheritance diagrams display that way) and subsequent
derivations are known as subclasses. When you want to use the code in a
super class from your sub class, you user super() to call it. So your sub
class (a derivation of your base class) needs to call into its super class,
it is done with a super() call. The super() call is (and must be) the first
statement in the subclass's overriding method.

All of this seems too easy, so I am sure I have completely missed the point.

Brian


- Original Message -
From: "Mohan Radhakrishnan" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, December 04, 2002 5:47 AM
Subject: abstract class



Hi,

  If an action has two different behaviours then it is advised to use an
abstract method in the base class that the sub-action can override.

  Our base action's perform method has to pass control to a sub action's
method for the varying behavior. But if we use an abstract method then the
action cannot be instantiated.

How is this usually done?
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]>





--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: abstract class

2002-12-05 Thread Mohan Radhakrishnan
Hi,
   I looked at the archives and found abstract base actions.

   1. I have two actions, the base handling the basic flow and the
sub-action handling the alternate flow. ( Apart from these two I have a
common base action which all actions extend containing login checks etc. )

   Now I wanted to pass the control to the sub-action when the alternate
flow happens. Usually it is polymorphism. Now with struts everything is
routed by the config.xml file. I can't call a method in the sub-action from
the base action ? Does it violate the struts flow ?

   That is why I decided to use an abstract method somewhere in the
hierarchy to be polymorphic but abstract classes can't be instantiated by
struts.

   That is what caused the confusion. Is my thinking right ?

The reason why I decided to have a sub-action instead of a helper class is
that in some cases it might be an independent action.

Thanks,
Mohan 

-Original Message-
From: Brian Hickey [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 04, 2002 5:56 PM
To: Struts Users Mailing List
Subject: Re: abstract class


Mohan,

Two different behaviors is what you wish then you need to derive from a
concrete base class. Abstract classes are more likely to provide conformance
to an architecture or signature template.

In Struts, folks usually inherit from the Action class to create certain
behaviors. If you need to super() to a base class, you are correct, it
cannot be an abstract class. I would suggest that it shouldn't be in most
any case, but I don't know your architecture.

It is also early and I am not sure of your terminology. A base class is a
super class (standard inheritance diagrams display that way) and subsequent
derivations are known as subclasses. When you want to use the code in a
super class from your sub class, you user super() to call it. So your sub
class (a derivation of your base class) needs to call into its super class,
it is done with a super() call. The super() call is (and must be) the first
statement in the subclass's overriding method.

All of this seems too easy, so I am sure I have completely missed the point.

Brian


- Original Message -
From: "Mohan Radhakrishnan" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, December 04, 2002 5:47 AM
Subject: abstract class


> Hi,
>
>If an action has two different behaviours then it is advised to use an
> abstract method in the base class that the sub-action can override.
>
>Our base action's perform method has to pass control to a sub action's
> method for the varying behavior. But if we use an abstract method then the
> action cannot be instantiated.
>
>  How is this usually done?
> 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]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: abstract class

2002-12-04 Thread Brian Hickey
LOL!

Yes. 'Tis true. I would suggest a different approach, but it is irrelevant.
I am simply trying to help someone to find an answer. Thanks for the
explanation :o)

Brian


- Original Message -
From: "Andrew Hill" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, December 04, 2002 7:44 AM
Subject: RE: abstract class


> 
> So your sub
> class (a derivation of your base class) needs to call into its super
class,
> it is done with a super() call. The super() call is (and must be) the
first
> statement in the subclass's overriding method.
> 
>
> Thats just for constructors. Ive got a few places where a subclass
overrides
> a normal method in which it checks something and if a certain condition is
> met it does some special behaviour, but if not makes a call to the
> superclass implementation of the method in order to proceed as normal.
Thats
> using the syntax super.doSomething(), while super() is what you use if
your
> in a constructor - in that case it must be the first statement, but for
> normal methods it can be called anytime.
>
> -Original Message-
> From: Brian Hickey [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, December 04, 2002 20:26
> To: Struts Users Mailing List
> Subject: Re: abstract class
>
>
> Mohan,
>
> Two different behaviors is what you wish then you need to derive from a
> concrete base class. Abstract classes are more likely to provide
conformance
> to an architecture or signature template.
>
> In Struts, folks usually inherit from the Action class to create certain
> behaviors. If you need to super() to a base class, you are correct, it
> cannot be an abstract class. I would suggest that it shouldn't be in most
> any case, but I don't know your architecture.
>
> It is also early and I am not sure of your terminology. A base class is a
> super class (standard inheritance diagrams display that way) and
subsequent
> derivations are known as subclasses. When you want to use the code in a
> super class from your sub class, you user super() to call it. So your sub
> class (a derivation of your base class) needs to call into its super
class,
> it is done with a super() call. The super() call is (and must be) the
first
> statement in the subclass's overriding method.
>
> All of this seems too easy, so I am sure I have completely missed the
point.
>
> Brian
>
>
> - Original Message -
> From: "Mohan Radhakrishnan" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Sent: Wednesday, December 04, 2002 5:47 AM
> Subject: abstract class
>
>
> > Hi,
> >
> >If an action has two different behaviours then it is advised to use
an
> > abstract method in the base class that the sub-action can override.
> >
> >Our base action's perform method has to pass control to a sub
action's
> > method for the varying behavior. But if we use an abstract method then
the
> > action cannot be instantiated.
> >
> >  How is this usually done?
> > 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]>
>
>
> --
> 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]>




RE: abstract class

2002-12-04 Thread Andrew Hill

So your sub
class (a derivation of your base class) needs to call into its super class,
it is done with a super() call. The super() call is (and must be) the first
statement in the subclass's overriding method.


Thats just for constructors. Ive got a few places where a subclass overrides
a normal method in which it checks something and if a certain condition is
met it does some special behaviour, but if not makes a call to the
superclass implementation of the method in order to proceed as normal. Thats
using the syntax super.doSomething(), while super() is what you use if your
in a constructor - in that case it must be the first statement, but for
normal methods it can be called anytime.

-Original Message-
From: Brian Hickey [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 04, 2002 20:26
To: Struts Users Mailing List
Subject: Re: abstract class


Mohan,

Two different behaviors is what you wish then you need to derive from a
concrete base class. Abstract classes are more likely to provide conformance
to an architecture or signature template.

In Struts, folks usually inherit from the Action class to create certain
behaviors. If you need to super() to a base class, you are correct, it
cannot be an abstract class. I would suggest that it shouldn't be in most
any case, but I don't know your architecture.

It is also early and I am not sure of your terminology. A base class is a
super class (standard inheritance diagrams display that way) and subsequent
derivations are known as subclasses. When you want to use the code in a
super class from your sub class, you user super() to call it. So your sub
class (a derivation of your base class) needs to call into its super class,
it is done with a super() call. The super() call is (and must be) the first
statement in the subclass's overriding method.

All of this seems too easy, so I am sure I have completely missed the point.

Brian


- Original Message -
From: "Mohan Radhakrishnan" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, December 04, 2002 5:47 AM
Subject: abstract class


> Hi,
>
>If an action has two different behaviours then it is advised to use an
> abstract method in the base class that the sub-action can override.
>
>Our base action's perform method has to pass control to a sub action's
> method for the varying behavior. But if we use an abstract method then the
> action cannot be instantiated.
>
>  How is this usually done?
> 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]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: abstract class

2002-12-04 Thread Brian Hickey
Mohan,

Two different behaviors is what you wish then you need to derive from a
concrete base class. Abstract classes are more likely to provide conformance
to an architecture or signature template.

In Struts, folks usually inherit from the Action class to create certain
behaviors. If you need to super() to a base class, you are correct, it
cannot be an abstract class. I would suggest that it shouldn't be in most
any case, but I don't know your architecture.

It is also early and I am not sure of your terminology. A base class is a
super class (standard inheritance diagrams display that way) and subsequent
derivations are known as subclasses. When you want to use the code in a
super class from your sub class, you user super() to call it. So your sub
class (a derivation of your base class) needs to call into its super class,
it is done with a super() call. The super() call is (and must be) the first
statement in the subclass's overriding method.

All of this seems too easy, so I am sure I have completely missed the point.

Brian


- Original Message -
From: "Mohan Radhakrishnan" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, December 04, 2002 5:47 AM
Subject: abstract class


> Hi,
>
>If an action has two different behaviours then it is advised to use an
> abstract method in the base class that the sub-action can override.
>
>Our base action's perform method has to pass control to a sub action's
> method for the varying behavior. But if we use an abstract method then the
> action cannot be instantiated.
>
>  How is this usually done?
> 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]>




abstract class

2002-12-04 Thread Mohan Radhakrishnan
Hi,

   If an action has two different behaviours then it is advised to use an
abstract method in the base class that the sub-action can override.

   Our base action's perform method has to pass control to a sub action's
method for the varying behavior. But if we use an abstract method then the
action cannot be instantiated.

 How is this usually done?
Thanks,
mohan

--
To unsubscribe, e-mail:   
For additional commands, e-mail: