Hi all,

When I upload a file I would like for it to stay in memory for a bit until
user decides if he wants to save it or not (he can also then use the from
to add some more information about the file).

To achieve this I have created a class

public class UploadedFileStreamResponse implements StreamResponse {

    private UploadedFile uploadedFile;

    public UploadedFileStreamResponse(UploadedFile uploadedFile) {
        this.uploadedFile = uploadedFile;
    }

    @Override
    public String getContentType() {
        return uploadedFile.getContentType();
    }

    @Override
    public InputStream getStream() throws IOException {
        return uploadedFile.getStream();
    }

    @Override
    public void prepareResponse(Response response) {
    }
}

When a file is uploaded vie ajax it triggers a zone refresh, then it checks
to see if the file is added to the list and if so it triggers a component
event that returns the class above


    public Link getUploadedImageLink() {
        return resources.createEventLink(UPLOAD_IMAGE_EVENT});
    }

    @OnEvent(UPLOAD_IMAGE_EVENT)
    public StreamResponse getUploadedFileStream() {
        return new UploadedFileStreamResponse(uploadedFile);
    }


This works all way however I would like to extend this behaviour. I would
like to add the crop ability. The tapestry-jquery has this build in however
it receives a Asset object and not the component event link :)

Any idea how I can transform this into tapestry Asset?

Thanks all.

Cheers
Boris
-- 
Sincerely
*Boris Horvat*

Reply via email to