Hello.

This is the link from the stackoverflow question if you would like to 
answer there also: 
http://stackoverflow.com/questions/11151996/how-to-use-dispatch-actions-on-android/11152042#comment14622740_11152042

I am working on a project hosted on AppEngine, and for the browser client I 
am using the GWTP platform which implies using GIN (on the client) and 
GUICE on the server. Also, it uses Models, presenters, actions and events.

I am thinking of also writing an android client for the service but I don't 
know how to start because I don't know how to connect and exchange data 
with the webservice. I would have to use Actions and Action Handlers ( 
http://code.google.com/p/gwt-platform/wiki/GettingStartedDispatch ) which I 
use for the browser client. From Android I only know how to do it with RPC, 
and I can't make the connection, I don't know how to map classes from the 
device to the server.

For example, by using GWTP, if on the browser client I want to do something 
on the server, I implement an Action class, an ActionResult class ( both on 
the client ) and an ActionHandler class (on the server). To dispatch an 
action, I use the DispatchAsync interface and to get the result I use 
AsyncCallback.

Action (on the client ) - SendRoadNotification.java :

public class SendRoadNotification extends
    ActionImpl<SendRoadNotificationResult> {

private RoadNotification roadNot;



@SuppressWarnings("unused")
private SendRoadNotification() {
    // For serialization only
    }

public SendRoadNotification(RoadNotification roadNot) {
    this.roadNot = roadNot;
    }

public RoadNotification getRoadNot() {
    return roadNot;
    }
}

ActionResult (on the client ) -- SendRoadNotfifcationResult.java :

public class SendRoadNotificationResult implements Result {

private RoadNotification roadNot;

@SuppressWarnings("unused")
private SendRoadNotificationResult() {
    // For serialization only
    }

public SendRoadNotificationResult(RoadNotification roadNot) {
    this.roadNot = roadNot;
    }

public RoadNotification getRoadNot() {
    return roadNot;
    }
}

ActionHandler ( on the server ) -- SendRoadNotificationActionHandler.java :

public class SendRoadNotificationActionHandler implements
    ActionHandler<SendRoadNotification, SendRoadNotificationResult> {

static DataStore ds = DataStore.getDatastoreService();

@Inject
public SendRoadNotificationActionHandler() {
    }

@Override
public SendRoadNotificationResult execute(SendRoadNotification action,
        ExecutionContext context) throws ActionException {

                        //Here I am doing something with that action
    }

@Override
public void undo(SendRoadNotification action,
        SendRoadNotificationResult result, ExecutionContext context)
        throws ActionException {
    }

@Override
public Class<SendRoadNotification> getActionType() {
    return SendRoadNotification.class;
        }
}

The way I use those, is:

    SendRoadNotification action = new SendRoadNotification(rn);
            dispatchAsync.execute(action, sendRoadNotifCallback);

And the callback:

AsyncCallback<SendRoadNotificationResult> sendRoadNotifCallback = new 
AsyncCallback<SendRoadNotificationResult>() {

    @Override
    public void onSuccess(SendRoadNotificationResult result) {


    }

    @Override
    public void onFailure(Throwable caught) {
        Window.alert("Something went wrong");

    }

};

How can I implement this in android ? Can somebody give me an example or 
had this problem before ?

I am using AppEngine sdk 1.6.4, GWT sdk 2.4.0, GWTP plugin for Eclipse and 
GPE plugin for Eclipse.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to