Skip to content

Instantly share code, notes, and snippets.

@dizzi
Created August 19, 2009 20:18
Show Gist options
  • Save dizzi/170633 to your computer and use it in GitHub Desktop.
Save dizzi/170633 to your computer and use it in GitHub Desktop.
blogout = new Button("Registrovat");
blogout.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent sender) {
RequestBuilder request = new RequestBuilder(RequestBuilder.POST, GWT.getModuleBaseURL()
+ "userhandling/createUser");
request.setRequestData("username=" + user.getText() + "&password=" + pass.getText() + "&im=" + im.getText()
+ "&email=" + email.getText());
request.setHeader("Content-Type", "application/x-www-form-urlencoded");
request.setCallback(new RequestCallback() {
public void onError(Request request, Throwable exception) {
Freza.infoPopUp("Komunikace se serverem selhala", Freza.ERR);
}
public void onResponseReceived(Request request, Response response) {
JSONValue jvalue = JSONParser.parse(response.getText());
JSONObject jobject = jvalue.isObject();
if(jobject == null || jobject.get("result").isString().stringValue().equalsIgnoreCase("error")){
Freza.infoPopUp("Chyba: "+jobject.get("desc").isString().stringValue(), Freza.ERR);
return;
} else if(jobject.get("result").isString().stringValue().equalsIgnoreCase("success")){
// TODO [x] if registration successful
Freza.loginListener.notifyLogout();
tp.selectTab(0);
Freza.infoPopUp("Registrovano, pockej na autorizaci adminem", Freza.OK);
} else {
Freza.infoPopUp("Pri registraci doslo k nejake nekalosti, zkus znova", Freza.WRN);
}
}
});
try {
Log.info("Request - create user");
request.send();
} catch (RequestException e) {
Freza.infoPopUp("Neco slo spatne... hodne", Freza.ERR);
Log.error("register button", e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment