views:

160

answers:

1

I'm uploading a file using FileUpload and a FormPanel, on the server I generate a List using the data from the uploaded file. The problem is that I need to display this List on the client, but I can't find a way to serialize it using GWT's serialization in a normal HttpServlet. Only in RemoteServiceServlets which can't process a FormPanel's request.

Also, I wouldn't even know how to deserialize the Object on the client after I got it from the SubmitCompleteEvent.

A: 

I've developed a custom solution for this in the company I work for. It uses some code from the gwt-upload project. The idea behind what I've made is:

  • a helper servlet for uploading
    • receives files via post requests
    • provide recently uploaded files download via get requests (param include ID)
  • a file service for administrative tasks
    • getting a unique ID for file uploading to the servlet
    • asking how is the upload status (percent, error, cancel, ok)
    • asking for "download urls" (basically checks the file exists and provides servletURL+id)

I've declared the structure for handling the temporal uploaded files statically. That way it's globally visible for the servlet and for the GWT Controller. If you don't like it you could also do some initialization in a contextlistener and store a reference to the global file uploading system in Application context. That way the GWT Service implementation and the servelt implementation could access it anyway.

helios