Hi all,

I am currently writing an implementation for a modern file upload based on dropzone.js:

https://github.com/l0rdn1kk0n/wicket-bootstrap/issues/371

I am using AbstractDefaultAjaxBehavior to send the files back to the server. At this place I need to adjust the AbstractDefaultAjaxBehavior to enable it for multipart:

        @Override
        protected AjaxRequestAttributes getAttributes()
        {
            AjaxRequestAttributes attributes = super.getAttributes();
            attributes.setMultipart(true);
            return attributes;
        }

Currently getAttributes() is set to final and I have no chance to change the AjaxRequestAttributes anyhow - so my suggestion would be to add a protected method which is called within getAttributes() so that it is possible to change the AjaxRequestAttributes.

An example implementation in the response method of the AbstractDefaultAjaxBehavior would be:

ServletWebRequest webRequest = (ServletWebRequest)getRequest(); MultipartServletWebRequest multiPartRequest = webRequest.newMultipartWebRequest(
                        Bytes.bytes(5000000), "ignored");
                    multiPartRequest.parseFileParts();
Map<String, List<FileItem>> files = multiPartRequest.getFiles();
                    System.out.println(files);

I checked it already with a demo file and the log result was:

{file=[name=dropzone.js, StoreLocation=/var/folders/jh/dw7vk3rs1fbf5gyms4v9k85r0000gn/T/upload_9a1ae025_411f_4e82_8f04_70dc9a7e0a79_79336009.tmp, size=63014bytes, isFormField=false, FieldName=file]}

What do you think of adding a method to change the AjaxRequestAttributes for AbstractDefaultAjaxBehavior?

kind regards

Tobias

Reply via email to