Example usage for com.google.gwt.gadgets.client.gwtrpc GadgetsGwtRpc redirectThroughProxy

List of usage examples for com.google.gwt.gadgets.client.gwtrpc GadgetsGwtRpc redirectThroughProxy

Introduction

In this page you can find the example usage for com.google.gwt.gadgets.client.gwtrpc GadgetsGwtRpc redirectThroughProxy.

Prototype

public static void redirectThroughProxy(ServiceDefTarget serviceDef) 

Source Link

Document

Redirects passed service through gadgets container which makes GWT RPC possible in Gadgets environment.

Usage

From source file:com.google.gwt.gadgets.sample.gadgetrpc.client.GadgetRPC.java

License:Apache License

@Override
protected void init(GadgetRPC.Preferences preferences) {

    gadgetService = GWT.create(GadgetService.class);
    ServiceDefTarget serviceDef = (ServiceDefTarget) gadgetService;
    String rpcUrl = serviceDef.getServiceEntryPoint();

    // Uses Gadgets container as proxy for GWT RPC requests
    GadgetsGwtRpc.redirectThroughProxy(serviceDef);

    // Build the user interface.
    VerticalPanel vp = new VerticalPanel();
    vp.setWidth("100%");

    vp.add(new Label("RPC to: " + rpcUrl));

    HorizontalPanel startedHp = new HorizontalPanel();
    startedHp.add(new Label("Server Start Time: "));
    startedHp.add(serverStartedText);/* ww  w.ja va 2  s  .  c om*/
    vp.add(startedHp);

    HorizontalPanel currentHp = new HorizontalPanel();
    currentHp.add(new Label("Server Current Time: "));
    currentHp.add(serverCurrentText);
    vp.add(currentHp);

    Button doRPCButton = new Button("Call RPC Method");
    vp.add(doRPCButton);

    vp.add(exceptionInfo);

    RootPanel.get().add(vp);

    // Setup a button listener to invoke the RPC.
    doRPCButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            gadgetService.getServerInfo(rpcCallback);
        }
    });
}