RE: Delegating the request processing to an Action class

2001-07-07 Thread Craig R. McClanahan

I would not be too concerned about the performance impact of Oleg's
suggested approach.  After all, the controller servlet is just going to do
a RequestDispatcher.forward() back to itself, which has no more
performance impact than the usual RequestDispatcher.forward() used to
transfer control to a JSP page in the usual case.

Craig


On Wed, 27 Jun 2001, Rey Francois wrote:

> 
> This will work as well indeed, and is a lot simpler than what I suggested.
> However it will go through the web server layers again before it gets to the
> container and then the ActionServlet, which will do the usual things as with
> any request. The solution I proposed was more an optimized solution and
> should be considered only if performance is an issue. We actually developped
> this solution as part of a DispatcherAction, which we use in forms so that
> the submit can forward to more than one action (using a parameter which
> contains the action path preceded by a special prefix).
> 
> Fr.
> 
> -Original Message-
> From: Oleg V Alexeev [mailto:[EMAIL PROTECTED]]
> Sent: 27 June 2001 14:39
> To: [EMAIL PROTECTED]
> Subject: Re: Delegating the request processing to an Action class
> 
> 
> Hello ssuku,
> 
> Wednesday, June 27, 2001, 4:24:58 PM, you wrote:
> 
> 
> 
> shhc> Hi,
> shhc>  How can a  request processing be delegated from an Action class
> to
> shhc> another?
> 
> shhc> Thanks
> shhc> Sandhya
> 
> Return forward to another action -
> 
>  return new ActionForward( "someaction.do" );
> 
> 
> 
> -- 
> Best regards,
>  Olegmailto:[EMAIL PROTECTED]
> 
> 
> 
> The information in this email is confidential and is intended solely
> for the addressee(s).
> Access to this email by anyone else is unauthorised. If you are not
> an intended recipient, you must not read, use or disseminate the
> information contained in the email.
> Any views expressed in this message are those of the individual
> sender, except where the sender specifically states them to be
> the views of Capco.
> 
> http://www.capco.com
> ***
> 
> 




RE: Delegating the request processing to an Action class

2001-06-27 Thread Rey Francois


This will work as well indeed, and is a lot simpler than what I suggested.
However it will go through the web server layers again before it gets to the
container and then the ActionServlet, which will do the usual things as with
any request. The solution I proposed was more an optimized solution and
should be considered only if performance is an issue. We actually developped
this solution as part of a DispatcherAction, which we use in forms so that
the submit can forward to more than one action (using a parameter which
contains the action path preceded by a special prefix).

Fr.

-Original Message-
From: Oleg V Alexeev [mailto:[EMAIL PROTECTED]]
Sent: 27 June 2001 14:39
To: [EMAIL PROTECTED]
Subject: Re: Delegating the request processing to an Action class


Hello ssuku,

Wednesday, June 27, 2001, 4:24:58 PM, you wrote:



shhc> Hi,
shhc>  How can a  request processing be delegated from an Action class
to
shhc> another?

shhc> Thanks
shhc> Sandhya

Return forward to another action -

 return new ActionForward( "someaction.do" );



-- 
Best regards,
 Olegmailto:[EMAIL PROTECTED]



The information in this email is confidential and is intended solely
for the addressee(s).
Access to this email by anyone else is unauthorised. If you are not
an intended recipient, you must not read, use or disseminate the
information contained in the email.
Any views expressed in this message are those of the individual
sender, except where the sender specifically states them to be
the views of Capco.

http://www.capco.com
***




RE: Delegating the request processing to an Action class

2001-06-27 Thread Rey Francois

I while ago I had the same question. It was a bit tricky at that time and
don't know if it's made any easier now.
The problem is that you can always create your own instance of the Action,
but this is not the ideal solution.
Ideally you would like to use the instance cached by the ActionServlet.

Here is how we solved this problem.

1- Derive from the ActionServlet and create this method:
public Action getAction(ActionMapping mapping, HttpServletRequest
request)
{
return processActionCreate(mapping, request);
}

You have to do this because the processActionCreate is protected in
ActionServlet.

2- In struts-config.xml, you need to have a mapping that maps to the action
you want to delegate to. Then the following code should work in your Action:

//Find the mapping
ActionMapping aMapping = getServlet().findMapping("/" + match);

//Retrieve the action instance, associated with the actionmapping
Action delegate = ((MyServletClass)getServlet()).getAction(aMapping,
request);

//This will return an ActionForward
return delegate.perform(aMapping, form, request, response);


If you don't have or don't want to have a mapping for your delegate action
in struts-config.xml, then you can directly access the actions cache in your
servlet like it is done in processActionCreate()


Hope this helps,

Fr.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 27 June 2001 14:25
To: [EMAIL PROTECTED]
Subject: Delegating the request processing to an Action class




Hi,
 How can a  request processing be delegated from an Action class to
another?

Thanks
Sandhya



The information in this email is confidential and is intended solely
for the addressee(s).
Access to this email by anyone else is unauthorised. If you are not
an intended recipient, you must not read, use or disseminate the
information contained in the email.
Any views expressed in this message are those of the individual
sender, except where the sender specifically states them to be
the views of Capco.

http://www.capco.com
***




Re: Delegating the request processing to an Action class

2001-06-27 Thread Oleg V Alexeev

Hello ssuku,

Wednesday, June 27, 2001, 4:24:58 PM, you wrote:



shhc> Hi,
shhc>  How can a  request processing be delegated from an Action class to
shhc> another?

shhc> Thanks
shhc> Sandhya

Return forward to another action -

 return new ActionForward( "someaction.do" );



-- 
Best regards,
 Olegmailto:[EMAIL PROTECTED]





Delegating the request processing to an Action class

2001-06-27 Thread ssuku



Hi,
 How can a  request processing be delegated from an Action class to
another?

Thanks
Sandhya