开发者

Uncaught exception in GWT after http request

I have an web application created with GWT which interacts with a server via http requests to php files. I make a request to the following php file: http://localhost/bibliotheek/php/addUser.php?username=username.test2&group=test&admin=false&password=&topadmin=false

When I do this in hosted mode (so after compiling) I get the following exception:

uncaught exception: [Exception... "'java.lang.NumberFormatException: For input string: ""' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "JS frame :: chrome://firebug/content/spy.js :: callPageHandler :: line 744" data: no]

Line 0

I get this exception only with this request, not with other requests. I make the request with the following code:

protected void addUserToTheDatabase(String[] data) {


    String file = "addUser.php?username=" + data[0] + "&group=" + data[1] + "&admin=" + 
                  data[2] + "&password=" + data[3] + "&topadmin=" + data[4];

    request object = new request(); 
    object.getMessageXml(file, "GET", "null", new AsyncCallba开发者_开发技巧ck<String>() {

        @Override
        public void onFailure(Throwable caught) {
            new UserInterface.notification(BibPhp.error.INTERNET_CONNECTION);   
            caught.getMessage();
        }

        @Override
        public void onSuccess(String result) {

            if(Integer.parseInt(result) == 0) {
                new UserInterface.notification("Deze gebruikersnaam is reeds in gebruik.");
            }
            else {
                new UserInterface.notification("Gebruiker toegevoegd.");
            }
            new add(false);
        }
    });
}

I have no idea what I do wrong because all the other requests or exact the same, just to an other file. The php file doesn't generate a a response, so that can make any influence.

Any other people that experienced this problem or any suggestions?

Thanks in advance.


In your onSuccess method you do an Integer.parseInt(result). If the value of result is "" you might get the above exception. I would confirm that the value of result is actually a number and not an empty string. You can also put a try ... catch around the parseInt call to catch the NumberFormatException and notify the user.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜