views:

75

answers:

1

Hello

I have and Google Web Toolkit (Multipart) Form which post a file to my servlet. When error condition is happening in servlet I return an error. When everything is OK I return an JSON string.

    ...
    response.setContentType("text/html");
    response.setCharacterEncoding("UTF8");
    response.getWriter().write(out.toString());

} catch (FileUploadException e) {
    response.sendError(500, e.getMessage());
} catch (Exception e) {
    response.sendError(500, e.getMessage());
}

The problem is that I cant find a way to handle this in client side. This is the event that is fired when post goes OK and when error code is returned. But I can't find how to find is it OK or NOT? And how can I get an error message from Exception in client code?

@UiHandler("form")
void submitComplete(SubmitCompleteEvent event)
{
    ...

Debug

+1  A: 

Currently, there doesn't seem to be a suitable method available (like Response's getStatusCode). You have to do with the error documents your server returns to you in SubmitCompleteEvent.getResults(). You can make this task easier by setting custom error documents on your server (which you should either way for your production server) that are easier to parse/handle.

Related threads on GWT's Google Group: one and two.

Igor Klimer