|
Readme
Quick startup guide
IntroductionHere's a short introduction how to use gwt-hermes. Details1. download gwt-hermes.jar 2. add Hermes to your module file add a section that will look like this: <inherits name="com.overto.gwt.hermes.Hermes" /> 3. declare an interface of JSON service you want to call Exactly like in case of GWT RPC you have to define an interface of your service, i.e.: public interface TestService extends RemoteJSONService {
public int testMethod(String param);
}PLEASE NOTE:
classes have to expose properties by public getters and setters 4. declare an async interface for your service Again exactly the same as in GWT RPC: public interface TestServiceAsync {
public void testMethod(String param, AsyncCallback callback);
}PLEASE NOTE:
5. use GWT.create to create async version of your interface TestServiceAsync testService = (TestServiceAsync) GWT.create(TestService.class); 6. use JSONServiceDefTarget to configure service address Once again - exactly like in GET RPC: JSONServiceDefTarget serviceTarget = (JSONServiceDefTarget) testService;
serviceTarget.setServiceEntryPoint("http://foo.com/json");
serviceTarget.setAppendMethodNameToAddress(false);PLEASE NOTE:
7. call your service Exactly the same syntax as in GWT here: testService.testMethod("a", new new AsyncCallback() {
public void onFailure(Throwable caught) {
Window.alert(caught.toString());
}
public void onSuccess(Object result) {
Window.alert(result.toString());
}
});The result can be cast to the result type of the method. Enjoy! |
Sign in to add a comment
seems like there is a typo:
testService.testMethod("a", new new AsyncCallback?() {
should be:
testService.testMethod("a", new AsyncCallback?() {