GWT RPC RPC plumbing diagram RPC plumbing diagram
GWT - RPC
RPC plumbing diagram
RPC plumbing diagram package com. mycompany. client; import com. google. gwt. user. client. rpc. Remote. Service; public interface My. Add. Service extends Remote. Service { public int add(int a, int b); }
RPC plumbing diagram package com. mycompany. server; import com. google. gwt. user. server. rpc. Remote. Service. Servlet; import com. mycompany. client. My. Add. Service; public class My. Add. Service. Impl extends Remote. Service. Servlet implements My. Add. Service{ public int add(int a, int b) { int z = a + b; return z; } }
RPC plumbing diagram package com. mycompany. client; import com. google. gwt. user. client. rpc. Async. Callback; public interface My. Add. Service. Async { public void add(int a, int b, Async. Callback callback); }
Deploy service Tomcat -> add Servlet Hosted mode -> modify module XML <module> <inherits name='com. google. gwt. user. User'/> <entry-point class='com. mycompany. client. My. Application'/> <servlet path="/add. Service" class="com. mycompany. server. My. Add. Service. Impl“/> </module>
Actually making a call button. add. Click. Listener( new Click. Listener() { public void on. Click(Widget sender) { Add. Service. Async add. Service = (Add. Service. Async) GWT. create(Add. Service. class); Service. Def. Target endpoint = (Service. Def. Target) add. Service; String module. Relative. URL = GWT. get. Module. Base. URL() + "my. Add. Service“; endpoint. set. Service. Entry. Point(module. Relative. URL); instantiate service interface set service implementation url
Actually making a call button. add. Click. Listener( new Click. Listener() { public void on. Click(Widget sender) { Add. Service. Async add. Service = (Add. Service. Async) GWT. create(Add. Service. class); Service. Def. Target endpoint = (Service. Def. Target) add. Service; String module. Relative. URL = GWT. get. Module. Base. URL() + "my. Add. Service“; endpoint. set. Service. Entry. Point(module. Relative. URL); Async. Callback callback = new Async. Callback(){ public void on. Success(Object result){ resultaat. Label. set. Text(result. to. String()); } public void on. Failure(Throwable caught) { resultaat. Label. set. Text(caught. get. Message()); } create an asynchronous callback to handle the result
Actually making a call button. add. Click. Listener( new Click. Listener() { public void on. Click(Widget sender) { Add. Service. Async add. Service = (Add. Service. Async) GWT. create(Add. Service. class); Service. Def. Target endpoint = (Service. Def. Target) add. Service; String module. Relative. URL = GWT. get. Module. Base. URL() + "my. Add. Service“; endpoint. set. Service. Entry. Point(module. Relative. URL); Async. Callback callback = new Async. Callback(){ public void on. Success(Object result){ resultaat. Label. set. Text(result. to. String()); } public void on. Failure(Throwable caught) { resultaat. Label. set. Text(caught. get. Message()); } }; add. Service. add(Integer. parse. Int(a. Box. get. Text()), Integer. parse. Int(b. Box. get. Text()), callback); } ); } actually make the call
Actually making a call button. add. Click. Listener( new Click. Listener() { public void on. Click(Widget sender) { Add. Service. Async add. Service = (Add. Service. Async) GWT. create(Add. Service. class); Service. Def. Target endpoint = (Service. Def. Target) add. Service; String module. Relative. URL = GWT. get. Module. Base. URL() + "my. Add. Service“; endpoint. set. Service. Entry. Point(module. Relative. URL); Async. Callback callback = new Async. Callback(){ public void on. Success(Object result){ resultaat. Label. set. Text(result. to. String()); } public void on. Failure(Throwable caught) { resultaat. Label. set. Text(caught. get. Message()); } }; add. Service. add(Integer. parse. Int(a. Box. get. Text()), Integer. parse. Int(b. Box. get. Text()), callback); } ); }
- Slides: 10