Package com.totsp.gwittir.example.client

Source Code of com.totsp.gwittir.example.client.StreamingExample

package com.totsp.gwittir.example.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Widget;
import com.totsp.gwittir.client.stream.StreamServiceCallback;
import com.totsp.gwittir.client.stream.impl.StreamingServiceStub;
import com.totsp.gwittir.client.ui.BoundVerticalPanel;
import com.totsp.gwittir.client.ui.Button;
import com.totsp.gwittir.client.ui.Label;
import com.totsp.gwittir.client.ui.util.BoundWidgetTypeFactory;

public class StreamingExample extends BoundVerticalPanel<Object> {

 
  public StreamingExample(){
    super(new BoundWidgetTypeFactory(),null);
   
    Button stream = new Button("Stream!");
        stream.addClickListener(new ClickListener() {
                public void onClick(Widget sender) {
                    ExampleStreamServiceAsync ser = (ExampleStreamServiceAsync) GWT.create(ExampleStreamService.class);
                    StreamingServiceStub stub = (StreamingServiceStub) ser;
                    stub.setServicePath(GWT.getModuleBaseURL() +
                        "ExampleStreamService");
                    ser.getResults(5, "foo",
                        new StreamServiceCallback<MyClass>() {
                            public void onReceive(MyClass object) {
                              add( new Label("Got: " + object.getName()));
                            }

                            public void onError(Throwable thrown) {
                                Window.alert("Thrown: " + thrown.toString());
                            }

                            public void onComplete() {
                                add( new Label("complete."));
                            }
                        });
                }
            });
       
        add(stream);
  }
}
TOP

Related Classes of com.totsp.gwittir.example.client.StreamingExample

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.