Skip to content

Instantly share code, notes, and snippets.

@deepaksinghvi
Created July 24, 2012 03:32
Show Gist options
  • Save deepaksinghvi/3167849 to your computer and use it in GitHub Desktop.
Save deepaksinghvi/3167849 to your computer and use it in GitHub Desktop.
callServerSerivce
Button btnAdd = new Button("Add");
btnAdd.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
User user = new User();
user.setUserName(nameTextBox.getText());
user.setPassword(passwordTextBox.getText());
MongoDBServiceAsync mongoDBServiceAsync = GWT
.create(MongoDBService.class);
ServiceDefTarget serviceDef = (ServiceDefTarget) mongoDBServiceAsync;
serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
+ "dbservice");
mongoDBServiceAsync.setUser(user, new AsyncCallback<Void>(){
@Override
public void onFailure(Throwable caught) {
Window.alert("User addition failed, reason: " +caught.getMessage());
}
@Override
public void onSuccess(Void result) {
Window.alert("User addition successful");
}
});
}
});
btnAdd.setText("Add Users");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment