The Action class normally has a reference to the ActionServlet that is set
by the ActionServlet or RequestProcessor (I forget which) when the object is
instantiated. If you are instantiating an Action instance yourself you will
want to set it, in case the code in the other action needs to get at the
servlet reference (or through it to get the ServletContext reference).

Action myAction = new MyAction();
myAction.setServlet( getServlet() );
myAction.execute(mapping, form, request, response);

Hmm. setServlet() is public in 1.1 final release, but Ive noticed in the
nightly docs it now seems to be package protected. That could be very bad
for a framework extension Im working on. :-(

-but its also another good indication that you ought to factor out the
common code into a third class rather than trying to re-use the action! ;-)

-----Original Message-----
From: Ashok.D [mailto:[EMAIL PROTECTED]
Sent: Thursday, 4 September 2003 22:45
To: Struts Users Mailing List; [EMAIL PROTECTED]
Subject: Re: Can we create a Action class object


Hi Andrew Hill,

Thanks for your reply.

Can I know about " setting the ActionServlet reference first!".

Thanks & Regards,
Ashok.D
----- Original Message -----
From: "Andrew Hill" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Thursday, September 04, 2003 7:58 PM
Subject: RE: Can we create a Action class object


> Sure, just instantiate it and call its perform (execute in struts 1.1)
> method, passing your mapping, for, request and response refs. Dont forget
to
> set the ActionServlet reference first!
> (Of course it gets much more complicated if you dont want to give it the
> same mapping and form as your calling action is using! :-( )
>
> <disclaimer>
> Like action-chaining the need to do this is however probably a good
> indication that your actions have too much business logic in them (which
> should be in business classes invoked by the actions) and you might want
to
> consider how you could improve your architecture a bit!
> </disclaimer>
>
> -----Original Message-----
> From: Ashok.D [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 4 September 2003 21:42
> To: Struts Users Mailing List
> Subject: Can we create a Action class object
>
>
> Hi,
>
> Can we create a Action class object. I need to access the perform method
> from another Action class.
>
> If we access this Action class by using *.do, I have some limiations in my
> application. I don't want to use action.do.
>
> But I need to execute another action class perform method.
>
> Pls put some light on this issue.
>
> Thanks & Regards,
> Ashok.D
>
>
> ---------------------------------------------------------------------
> 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]

Reply via email to