Sounds good to me! I am used to the rpc calls and I did not work with
json yet.

Seems that I have to do it! Thank you both for your time!

Regards,
Zé Vicente

On 25 ago, 17:12, Thomas Broyer <t.bro...@gmail.com> wrote:
> On 25 août, 16:09, Zé Vicente <josevicentec...@gmail.com> wrote:
>
>
>
>
>
> > Hello all,
>
> > This thread is about the result we get back after we submit a
> > FormPanel. I'm using a FormPanel + FileUpload in order to upload
> > photos in my GWT app.
>
> > When I submit the form, there is a servlet that takes care of the
> > request and saves the image on server side. I also have an object
> > called "Image" (from my business model) that is created to represent
> > the file just uploaded. This object contains the path of the image, a
> > small description and etc. I need to have this object sent back to the
> > UI.
>
> > So, what is the best way to get a reference to my object model "Image"
> > after form submission? Using FormPanel I am able to provide a handler
> > that will give access to the method x.getResults() which returns only
> > String generated by my servlet.
>
> > What is your experience with that?
>
> Our servlets send JSON (with "Content-Type: text/html" though, so that
> the SubmitCompleteEvent is reliably fired...) and we then parse
> e.getResults() on client-side.
> We're using JSON for all our server responses so the FormPanel
> integrates quite well with our other code based on RequestBuilder
> (you'd have guess: we don't use GWT-RPC).
>
> The issue you'll face with FormPanel (compared to RequestBuilder) is
> that there's no "error handler" (no onError / onFailure) and you
> cannot get the response status code either (as in
> Response.getStatusCode() when using RequestBuilder). So your server
> has to generate JSON (with content-type: text/html) to convey errors
> too, and your client code has to inspect the returned JSON to
> determine whether it's a success or failure.
> Our servlets in case or error always return a JSON object (we call it
> "status object") with the same properties ("statusCode", "message",
> etc.) mimicking HTTP-level information, and we baked the handling of
> the response in a common SubmitCompleteHandler wrapped around a
> RequestCallback/AsyncCallback-like callback (it parses the JSON, looks
> for "statusCode" and "message" properties; if they're present and
> "statusCode >= 400", then it calls the callback.onError(statusObject),
> otherwise it calls callback.onSuccess(parsedJsonObject)).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to