Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-2198

Integration of Struts 2 and DWR

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.0.10
    • 2.1.1
    • Integration
    • None
    • Patch

    Description

      In WebWorks there is a DWR and Struts 2 Integration using the DWRAction class where yo can invoke the Action methods using DWR. I implemented a similar class, but not with all the functionality with Struts 2. I've done a project with this integration and it works really great.

      public class DWRAction
      {
      private static final Logger log = Logger.getLogger (DWRAction.class);

      public static Object execute (ActionDefinition actionDefinition, Map params, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) throws Exception {
      ActionMapping mapping;
      Dispatcher dispatcher;
      Map context;
      ActionProxy proxy;

      try

      { dispatcher = Dispatcher.getInstance (); mapping = new ActionMapping (actionDefinition.getAction(), actionDefinition.getNamespace(), actionDefinition.getMethod(), params); context = dispatcher.createContextMap (request, response, mapping, servletContext); proxy = ((ActionProxyFactory) dispatcher.getContainer ().getInstance (ActionProxyFactory.class)).createActionProxy (actionDefinition.getNamespace (), actionDefinition.getAction (), context, false, false); proxy.setMethod (actionDefinition.getMethod ()); proxy.execute (); return (proxy.getAction ()); }

      catch (Exception e)

      { log.error ("Cannot invoke action '" + actionDefinition.getAction() + "' in namespace '" + actionDefinition.getNamespace() + "'", e); throw e; }

      }
      }

      In this case I'm invoking the actions method and returning the action to the JSP page so I can access attributes that were set in the invocation. It would be nice to have something like this part of the Struts 2 standard. If you need help implemening this solution I would gladly help.

      Attachments

        Activity

          People

            tschneider Thomas Schneider
            nestorjb Nestor Boscan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: