Additionally, I find that if you return an HTML document as the
response to the form submission, the value of getResults() is the
content of the body element in the HTML document.

I don't know if this is a good idea, but I return an HTML document
like...

<html><head><title>results</title></head><body><!-- [put anything you
want to process on submit complete inside this XML comment] --></
body></html>

... and then process the string I get from getResults(), which will be
"<!-- ... -->".

I actually want to send some XML back as the response to the form
submission, and initially tried putting the XML directly inside the
body element, but that has strange results, and so embed it in an XML
comment, then extract from there and parse.

This is an ugly hack, so any other suggestions very welcome.

In particular, the fact that you cannot get access to the status code
of the response is particularly annoying. It means you have to rely on
parsing the value of getResults() to determine whether the upload
failed or succeeded, which isn't consistent with the good practice of
relying on sensible HTTP status codes.

Cheers,

Alistair

On Jan 28, 8:09 am, Peter Ondruska <[email protected]> wrote:
> Thank you again Thomas, that makes sense now :-) Peter
>
> On 27 led, 12:18, Thomas Broyer <[email protected]> wrote:
>
> > On Jan 27, 9:12 am, Peter Ondruska <[email protected]> wrote:
>
> > > Thanks Thomas, for me it was not 
> > > obvious:http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/g...()
>
> > > "Returns: the result html, or null if there was an error reading it"
> > > perhaps it would be more clear to state "Returns: HTML encoded result
> > > regardless of content type returned by servlet..."
>
> > FormPanel submits to a hidden iframe, so it gets the result from the
> > iframe's content (hence the 'null' when you don't submit to the same
> > domain, because of the SOP), which is always seen as an HTML document,
> > even if it "represents" a text/plain or an image.
>
> > The hint is in FormPanel's no-arg constructor's 
> > javadoc:http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/g...()
> > """
> > The back-end server is expected to respond with a content-type of
> > 'text/html', meaning that the text returned will be treated as HTML.
> > If any other content-type is specified by the server, then the result
> > HTML sent in the onFormSubmit event will be unpredictable across
> > browsers, and the onSubmitComplete event may not fire at all.
>
> > Tip:
> > The initial implementation of FormPanel specified that the server
> > respond with a content-type of 'text/plain'. This has been
> > intentionally changed to specify 'text/html' because 'text/plain'
> > cannot be made to work properly on all browsers.
> > """

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to