On Sat, 2004-07-03 at 22:38, Sylvain Wallez wrote:
> Joerg Heinicke wrote:
>
> > This thread on users list was about implementing the setValue() method
> > on the upload widget. The use case is - as the subject says - editing
> > existing list of uploads. The complete thread can be found at
> > http://thread.gmane.org/gmane.text.xml.cocoon.user/38910. What has
> > been the reason for not implementing the method besides a missing use
> > case? No security reason came to my mind. What about implementing it
> > the most simple way:
> >
> > public void setValue(Object object) {
> > if (!(object instanceof Part)) {
> > throw new RuntimeException("not a part");
> > }
> > this.part = (Part) object;
> > }
>
>
> That makes sense. This allows for example forms that edit some data with
> binary attachements to display the existing attachments and newly added
> ones in a uniform way.
>
> However, as outlined in the discussion, the form binding will have to
> take care of distinguishing new and existing attachments, and also
> existing attachments that were deleted. But that's another problem.
>
> Something I've been thinking about also is a way to make the uploaded
> parts accessible from the browser. That would allow e.g. to display a
> preview of uploaded images.
>
> For low, let's add Upload.setValue() !
>
> Sylvain
Something that doesn't sit entirely right for me is that one would
'artificially' create a Part. While technically possible, the definition
of a Part is that it is a file parsed from a http post.
How about introducing a new interface for the value of an upload widget,
lets say UploadData:
UploadData {
/** Return true if it is newly uploaded data */
boolean isNew();
/** Returns the part if isNew returns true, otherwise null. */
Part getPart();
InputStream getInputStream();
String getMimeType();
}
This would also allow to distinguish between new and unmodified uploads.
--
Bruno Dumon http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
[EMAIL PROTECTED] [EMAIL PROTECTED]