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
***********************************************************************

Reply via email to