Re: Upload a file - special characters are converted to html chars?
On Thursday, April 4, 2013 10:36:20 PM UTC+2, Jens wrote:
As far as I know, GWT posts/submits to an iframe and then reads the iframe's content which you access through event.getResults(). So after a form submit is complete the iframe contains your server response. If you don't send back the uploaded file from server to client, SubmitCompleteEvent.getResults() will not contain your file contents. Its probably your server that sends back the & or you simply have a content type set on your server response which causes the browser to automatically escape your returned String because before GWT gives the result to you, it will end up in an iframe.For example I am used to return JSON if I need a more complex response from the server after submitting a form. Without the correct content type some browsers will return "<pre>JSON</pre>" on SubmitCompleteEvent.getResults().
SubmitCompleteEvent#getResults() is the body.innerHTML from the iframe, so the & is totally expected.
Other than that you can still decode the html entities without regex by using a hidden div element + innerHTML and then read back the rendered text: http://stackoverflow.com/a/1912522
If you must support browsers that don't have FormData (and thus cannot use XMLHttpRequest), then yes it's the only solution. And be very careful what your server sends in the response (make sure you escape & as & and < as < if you don't want to lose data)
-- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home