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)
{
...
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With