Alex Rivera | Logout

GWT: How to get a submission result out of FormPanel

Asked 2009-06-04T14:27:32.390
15

The example from FormPanel's javadoc says:

"...Assuming the service returned a response of type text/html, we can get the result text here (see the FormPanel documentation for further explanation)..."

However the javadoc doesn't explain a bit about this topic. Has anyone found how to get the HTML response sent back from server after a form submission?

Edit
Report

2 Answers

4

This problem only happens in a debug mode. Check this out: http://code.google.com/p/google-web-toolkit/issues/detail?id=3832

answered 2012-01-04T19:42:32.607
0

//=========== in the client side:

SubmitCompleteHandler sch = new SubmitCompleteHandler()
{
    public void onSubmitComplete(SubmitCompleteEvent event) 
    {
    //get back the data results that had input the .xml 
    String dpsString = event.getResults();

    //And do your wanted action with the result
    System.out.println(dpsString);
    }
};
uploadForm.addSubmitCompleteHandler(sch);   

//=========== in the server side:

// parse and handle file, e.g. if there is an xml file
...
InputStream fileImputStream = uploadItem.getInputStream();
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse(fileInputStream);
doc.getDocumentElement().normalize();
System.out.println("Root element of the doc is " + doc.getDocumentElement().getNodeName());
...
//Response to the request with the result  
dpsString = doc.getDocumentElement().getNodeName();
response.getWriter().write(new String(dpsString)); 
answered 2009-12-04T12:09:33.967

Your Answer