You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Puneet Agarwal <pu...@delhi.tcs.co.in> on 2003/10/22 14:02:24 UTC

Action to Action - Chaining

I had seen the discussion on Action Chaining, in developer's Forum.

We had an urgent need to implement this.

Following is the manner in which we achieved it.....does anyone think ..it
can pose problems to us in future....???
We declared the following method in the overridden DispatchAction class and
then I use it from my action classes.

X--------------X
  public ActionForward invokeMethod(HttpServletRequest request, String
action,
                                    String method, Object[] args)
         throws InvocationTargetException, IllegalAccessException
  {
    ModuleConfig config
= (ModuleConfig)request.getAttribute(Globals.MODULE_KEY);
    String key = Globals.REQUEST_PROCESSOR_KEY + config.getPrefix();
    ServletContext sc = request.getSession().getServletContext();
    TigerRequestProcessor processor
= (TigerRequestProcessor)sc.getAttribute(key);
    ActionClass ac = (ActionClass)processor.actions.get(action);
    Method[] methods =  ac.getClass().getDeclaredMethods();
    ActionForward af= null;
    for ( int i = 0 ; i < methods.length ; i++ )
    {
      if ( methods[i].getName().equals(method))
      {
        af = (ActionForward)methods[i].invoke(ac, args);
      }
    }
    return af;
  }
X--------------X
Regards,
Puneet Agarwal

Tata Consultancy Services,
C-56, Phase - II, NOIDA 201305 (India)
Phone: +91-120-2461001, 2, 7, 8, 9, 12, 13 (Ext. 1044)
FAX              : +91-120-246 1521

Struts ... Action ... Struts in Action ... Action in Struts ...

DISCLAIMER: The information contained in this message is intended only and
solely for the addressed individual or entity indicated in this message and
for the exclusive use of the said addressed individual or entity indicated
in this message (or responsible for delivery of the message to such person)
and may contain legally privileged and confidential information belonging
to Tata Consultancy Services. It must not be printed, read, copied,
disclosed, forwarded, distributed or used (in whatsoever manner) by any
person other than the addressee. Unauthorized use, disclosure or copying is
strictly prohibited and may constitute unlawful act and can possibly
attract legal action, civil and/or criminal. The contents of this message
need not necessarily reflect or endorse the views of Tata Consultancy
Services on any subject matter. Any action taken or omitted to be taken
based on this message is entirely at your risk and neither the originator
of this message nor Tata Consultancy Services takes any responsibility or
liability towards the same. Opinions, conclusions and any other information
contained in this message that do not relate to the official business of
Tata Consultancy Services shall be understood as neither given nor endorsed
by Tata Consultancy Services or any affiliate of Tata Consultancy Services.
If you have received this message in error, you should destroy this message
and may please notify the sender by e-mail. Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org