Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT: How to get a submission result out of FormPanel

Tags:

java

gwt

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?

like image 241
ciukes Avatar asked Jun 04 '09 14:06

ciukes


2 Answers

Add a FormHandler to your FormPanel, and in onSubmitComplete you will receive a FormSubmitCompleteEvent. Invoke its getResults() method to obtain the result.

form.addFormHandler(new FormHandler() {
    public void onSubmit(FormSubmitEvent event) { // validation etc }

    public void onSubmitComplete(FormSubmitCompleteEvent event} {

         Window.alert(event.getResults()); // display the result
    }

};
like image 57
Robert Munteanu Avatar answered Oct 19 '22 21:10

Robert Munteanu


Following the answear from "Robert Munteanu" you should look at:

http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/user/client/ui/FormPanel.SubmitCompleteEvent.html

And there you can see :

getResults

public java.lang.String getResults()

Gets the result text of the form submission.

Returns:

the result html, or null if there was an error reading it

Tip:

The result html can be null as a result of submitting a form to a different domain.

like image 30
Roman M Avatar answered Oct 19 '22 23:10

Roman M