Presentation is loading. Please wait.

Presentation is loading. Please wait.

GWT - RPC. RPC plumbing diagram package com.mycompany.client; import com.google.gwt.user.client.rpc.RemoteService; public interface MyAddService extends.

Similar presentations


Presentation on theme: "GWT - RPC. RPC plumbing diagram package com.mycompany.client; import com.google.gwt.user.client.rpc.RemoteService; public interface MyAddService extends."— Presentation transcript:

1 GWT - RPC

2 RPC plumbing diagram

3 package com.mycompany.client; import com.google.gwt.user.client.rpc.RemoteService; public interface MyAddService extends RemoteService { public int add(int a, int b); } RPC plumbing diagram

4 package com.mycompany.server; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.mycompany.client.MyAddService; public class MyAddServiceImpl extends RemoteServiceServlet implements MyAddService{ public int add(int a, int b) { int z = a + b; return z; } } RPC plumbing diagram

5 package com.mycompany.client; import com.google.gwt.user.client.rpc.AsyncCallback; public interface MyAddServiceAsync { public void add(int a, int b, AsyncCallback callback); } RPC plumbing diagram

6 Deploy service Tomcat -> add Servlet Hosted mode -> modify module XML

7 Actually making a call button.addClickListener( new ClickListener() { public void onClick(Widget sender) { AddServiceAsync addService = (AddServiceAsync) GWT.create(AddService.class); ServiceDefTarget endpoint = (ServiceDefTarget) addService; String moduleRelativeURL = GWT.getModuleBaseURL() + "myAddService“; endpoint.setServiceEntryPoint(moduleRelativeURL); AsyncCallback callback = new AsyncCallback(){ public void onSuccess(Object result){ resultaatLabel.setText(result.toString()); } public void onFailure(Throwable caught) { resultaatLabel.setText(caught.getMessage()); } }; addService.add(Integer.parseInt(aBox.getText()), Integer.parseInt(bBox.getText()), callback); } } );

8 In Eclipse: GWT Remote Service

9

10 Cypal studio maakt zelf Async interface en implementatie klasse aan, en past xml file aan Implementatie van methodes moet wel zelf voorzien worden Refresh werkt enkel voor client-side aanpassingen Bij server-side aanpassingen moet heel de applicatie herstart worden

11 Meer info web-toolkit-doc-1-5&s=google-web-toolkit-doc- 1-5&t=DevGuideRemoteProcedureCalls


Download ppt "GWT - RPC. RPC plumbing diagram package com.mycompany.client; import com.google.gwt.user.client.rpc.RemoteService; public interface MyAddService extends."

Similar presentations


Ads by Google