litesoft
@ 948
litesoft / trunk / GWT_Sandbox / gwtUITrimmed / src / com / gwtmobile / ui / kitchensink / client / communication / RpcPage.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
package com.gwtmobile.ui.kitchensink.client.communication; import com.google.gwt.core.client.*; import com.google.gwt.uibinder.client.*; import com.google.gwt.user.client.rpc.*; import com.google.gwt.user.client.ui.*; import com.gwtmobile.ui.client.event.*; import com.gwtmobile.ui.client.page.*; public class RpcPage extends Page { private static RpcPageUiBinder uiBinder = GWT.create( RpcPageUiBinder.class ); @UiField HTML text; interface RpcPageUiBinder extends UiBinder<Widget, RpcPage> { } public RpcPage() { initWidget( uiBinder.createAndBindUi( this ) ); } @UiHandler("list") void onListSelectionChanged( SelectionChangedEvent e ) { switch ( e.getSelection() ) { case 0: makeRpcCall(); break; } } private void makeRpcCall() { final RpcServiceAsync greetingService = GWT.create( RpcService.class ); //The code below sets service entry point to a server url. ServiceDefTarget service = (ServiceDefTarget) greetingService; String address = "http://gwtmobile-services.appspot.com/rpc"; service.setServiceEntryPoint( address ); greetingService.greetServer( "GWT Mobile UI", new AsyncCallback<String>() { @Override public void onSuccess( String result ) { text.setHTML( result ); } @Override public void onFailure( Throwable caught ) { text.setHTML( caught.getMessage() ); } } ); } } |