litesoft
@ 948
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
package org.litesoft.sandbox.csapp.client; import org.litesoft.sandbox.csapp.client.dtos.*; import org.litesoft.sandbox.csapp.client.widgets.*; import com.google.gwt.core.client.*; import com.google.gwt.event.dom.client.*; import com.google.gwt.user.client.rpc.*; import com.google.gwt.user.client.ui.*; /** * Entry point classes define <code>onModuleLoad()</code> */ public class CSapp implements EntryPoint { final CSappServiceAsync mService = GWT.create( CSappService.class ); private int mCalls; @Override public void onModuleLoad() { final Button button = new Button( "Click me" ); final Label label = new Label(); button.addClickHandler( new ClickHandler() { @Override public void onClick( ClickEvent event ) { if ( label.getText().equals( "" ) ) { if ( (++mCalls & 1) == 1 ) { mService.getMessage1( new Request1( "1-1", "1-2" ), new MyAsyncCallback<Response1>( label ) ); } else { mService.getMessage2( new Request2( "2-1", "2-2" ), new MyAsyncCallback<Response2>( label ) ); } } else { label.setText( "" ); } } } ); // Assume that the host HTML has elements defined whose // IDs are "slot1", "slot2". In a real app, you probably would not want // to hard-code IDs. Instead, you could, for example, search for all // elements with a particular CSS class and replace them with widgets. // RootPanel.get( "slot1" ).add( button ); RootPanel.get( "slot2" ).add( label ); RootPanel.get( "slot3" ).add( new MyPanel() ); } private static class MyAsyncCallback<T> implements AsyncCallback<T> { private Label label; public MyAsyncCallback( Label label ) { this.label = label; } @Override public void onSuccess( T result ) { label.getElement().setInnerHTML( result.toString() ); } @Override public void onFailure( Throwable throwable ) { throwable.printStackTrace(); label.setText( "Failed to receive answer from server!" ); } } } |
Commits for litesoft/trunk/GWT_Sandbox/CS_IDEA/src/org/litesoft/sandbox/csapp/client/CSapp.java
Revision | Author | Commited | Message |
---|---|---|---|
948 Diff | GeorgeS | Sat 07 Jun, 2014 23:42:39 +0000 | Jusefuls Formatter Updated to New Code Format |
613 Diff | GeorgeS | Thu 15 Mar, 2012 13:38:15 +0000 | Table Fix |
592 Diff | GeorgeS | Fri 20 Jan, 2012 20:23:50 +0000 | |
589 Diff | GeorgeS | Wed 18 Jan, 2012 19:16:02 +0000 | Unchecked & FE |
470 Diff | GeorgeS | Mon 29 Aug, 2011 04:25:43 +0000 | |
341 Diff | GeorgeS | Sun 31 Jul, 2011 23:42:21 +0000 | |
338 | GeorgeS | Sun 31 Jul, 2011 20:41:14 +0000 |