Skip to content
wan54 edited this page Sep 14, 2010 · 6 revisions

MSDwrProxy.j

A DWR proxy for Cappuccino app

Usage

Import this class:

@import "MSDwrProxy.j"

Say you have an exposed DWR Service class: DwrInterface and method: doSomething

You can call a DWR exposed method synchronously:

[[MSDwrProxy initialize] invokeWithMethod:DwrInterface.doSomething];

or with a single parameter:

[[MSDwrProxy initialize] invokeWithMethod:DwrInterface.doSomething parameter:aValue];

or with multiple parameters:

var params = [CPArray array];
[params addObject:value1];
[params addObject:value2];
[params addObject:value3];
[[MSDwrProxy initialize] invokeWithMethod:setSomeValue parameters:params];

If you’re calling an exposed method asynchronously, you must define a method that acts like javascript callback that will do some action after the call is completed, e.g.:

- (void)someAction:(id)data
{
}

Then you can call the method like so:

var dwrProxy = [MSDwrProxy initialize];
[dwrProxy setTarget:self];
[dwrProxy setAction:@selector(someAction:)];
[dwrProxy invokeWithMethod:DwrInterface.doSomething];

Example

This repository contains an example app that demonstrates the integration of Cappuccino app with Springframework and DWR. This app also demonstrates how Javascript and Objective-J can co-exist.

There are several files that you should look at to understand how the whole thing works:

  • web.xml
    • Entries added for DWR support.
  • applicationContext.xml
    • Entries added for DWR support.
  • index.html
    • Added DWR’s Javascript dependencies.
  • AppController.j
    • An example app.
  • MSDwrProxy.j
    • A proxy between Cappuccino app and DWR.
Clone this wiki locally