Struts 2 and DWR

View: New views
8 Messages — Rating Filter:   Alert me  

Struts 2 and DWR

by Néstor Boscán-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
 
I created a code based on the WebWork code that can invoke a Struts 2 Action from DWR. You can invoke it just like the WebWork version and you can use DWRActionUtil.js. It does not do everything that the WebWorks code does, it invokes de Action method and returns the Action object. Hope somebody finds it useful.
 
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;
    }
  }
}
 
Regards,
 
Néstor Boscán

Re: Struts 2 and DWR

by elaroche :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sounds great but dispatcher = Dispatcher.getInstance (); is always returning a null object.
Any Idea ? (Struts 2 : 2.0.11 and DWR 2.0.1)

Néstor Boscán-3 wrote:
Hi
 
I created a code based on the WebWork code that can invoke a Struts 2 Action
from DWR. You can invoke it just like the WebWork version and you can use
DWRActionUtil.js. It does not do everything that the WebWorks code does, it
invokes de Action method and returns the Action object. Hope somebody finds
it useful.
 
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;
    }
  }
}
 
Regards,
 
Néstor Boscán

Re: Struts 2 and DWR

by luckyshadab :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi
   Sir,
           PLEASE HELP ME
                   I want an example in which DWR, struts 2.0 and database(Oracle) should be used.
please give me an example code in which the following process should be done.
                       DATA SHOULD BE RETRIEVED FROM DATABASE USING DWR(direct web remoting) in struts 2.0...........
plz give me a small example so that i can understand it and try to utilize it in my application
plz its an request........
         

Re: Struts 2 and DWR

by davidmarginian :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

That is not what mailing lists are for.  We help people with problems, we don't provide applications for people.  I suggest you hire a professional developer if you can't work without a complete example.

On Fri, Oct 30, 2009 at 12:00 PM, luckyshadab <shadabprince@...> wrote:

hi
  Sir,
          PLEASE HELP ME
                  I want an example in which DWR, struts 2.0 and
database(Oracle) should be used.
please give me an example code in which the following process should be
done.
                      DATA SHOULD BE RETRIEVED FROM DATABASE USING
DWR(direct web remoting) in struts 2.0...........
plz give me a small example so that i can understand it and try to utilize
it in my application
plz its an request........

--
View this message in context: http://old.nabble.com/Struts-2-and-DWR-tp12314121p26134517.html
Sent from the DWR - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...



Re: Struts 2 and DWR

by luckyshadab :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

ok plz can u tell me how to retrieve data from database unsing DWR in struts 2.0

Re: Struts 2 and DWR

by davidmarginian :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I suggest looking at the dwr website and learning how to use dwr.  There are samples in the dwr.war.  Retrieving stuff from a database has nothing to do with dwr, do that however you normally do it and expose the methods to dwr.

On Fri, Oct 30, 2009 at 12:08 PM, luckyshadab <shadabprince@...> wrote:

ok plz can u tell me how to retrieve data from database unsing DWR in struts
2.0

--
View this message in context: http://old.nabble.com/Struts-2-and-DWR-tp12314121p26134616.html
Sent from the DWR - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...



Re: Struts 2 and DWR

by luckyshadab :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

can u plz tell me how this DWR words
can v use it in Struts 2.0

Re: Struts 2 and DWR

by Frank W. Zammetti :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

luckyshadab wrote:
> can u plz tell me how this DWR words
> can v use it in Struts 2.0
>  
I don't usually reply to things like this, and I usually hammer people
that answer in this sort of way, but in this case...

Dude, have you even TRIED to answer your own questions?  You're asking
some very fundamental questions that are pretty easily answered in about
ten minutes of Googling.  The DWR web site will give you a good
introduction to DWR itself, and there's literally thousands of tutorials
on database access with and without Oracle.  I'm sure if you come back
with some specific questions that indicate you've at least attempted to
help yourself first then you'll find people are willing to help (I for
one will).

Going up to a rocket scientist and asking how the fuel supply lines
you've read about feed into the first booster stage' engine will be
well-received... walking up to one and asking how to build an Atlas
rocket won't.

--
Frank W. Zammetti
Author of "Practical Palm Pre webOS Projects" (coming 12/2009)
  and "Practical Ext JS Projects with Gears"
  and "Practical Dojo Projects"
  and "Practical DWR 2 Projects"
  and "Practical JavaScript, DOM Scripting and Ajax Projects"
  and "Practical Ajax Projects with Java Technology"
  (For info: apress.com/book/search?searchterm=zammetti&act=search)
All you could possibly want is here: zammetti.com



__________ Information from ESET Smart Security, version of virus signature database 4559 (20091030) __________

The message was checked by ESET Smart Security.

http://www.eset.com



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...