Hi all,

Since I've seen many great answers on this list it's time to ask one of my 
questions ;-)

The thing that strikes me as odd is how hard it is right now to handle file 
uploads and respond as if it were an AJAX request.
I've built (based on various sources) a solution which uses a Panel which 
contains an IFRAME. After the upload, some AJAX javascript is rendered which 
calls an abstract function on the Panel so the implementor can replace or 
re-render components. This works great, although it took some extra effort 
since the frame and panel cannot easily share state (different 
pages/pagemaps/...?). The examples on the web store the uploaded file, and then 
pass it's filename through the AJAX request for access. I changed it to store 
uploads in temporary storage, identified by UUIDs.

Now I have to say I really don't like this solution, since the IFRAME has to be 
sized to fit, or I have to use some not-so-nice javascript to automatically 
resize the IFRAME when an upload error occurs.

Since I have had great fun with swfupload + PHP before, I decided to try and 
make an easier solution. I wondered if it would be possible to:

1) extend AbstractBehavior (works)
2) render the swf which will upload the file (works)
3) give the swf the URL of the behavior (works)
4) handle the upload(s) in onRequest() (does not work)
5) and then, just like AbstractDefaultAjaxBehavior.onRequest(), build an 
AjaxRequestTarget and handle the request (like it came in over xmlhttp) (works)
6) use javascript (Wicket.Ajax.Call.loadedCallback) to parse the (fake) AJAX 
response

Sounds possible, right? It just seems overkill to run a POST request _and_ an 
AJAX request for every upload. It seems more complex than it should be. 
Actually, with the IFRAME it's three requests: IFRAME GET, IFRAME POST, AJAX GET

What is not working right now is:
- POST request not directed to the Behavior (I'm assuming there is special-case 
handling for POST somewhere?)

Anyway, I'd like to known if any of the devs think the above is possible. If 
not, I'll stick to the solution I'm building right now (swfupload to a mounted 
URIRequestTargetUrlCodingStrategy + UUID in the URL, AJAX request with this 
UUID after successful upload).

Ofcourse it's also possible something like this is possible but needs a 
completely different angle.

Kind regards,

Bas

Reply via email to