Re: [cforms] Editing existing list of uploads

2004-07-06 Thread Sylvain Wallez
Bruno Dumon wrote:
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.
 

Do we really need a new abstraction, that furthermore depends on Part 
which it tries to hide? We could simply add isNew() to Part, and create 
some additional implementations, e.g. SourcePart whose isNew() would 
return false by default.

Sylvain
--
Sylvain Wallez  Anyware Technologies
http://www.apache.org/~sylvain   http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }


Re: [cforms] Editing existing list of uploads

2004-07-04 Thread Joerg Heinicke
On 04.07.2004 12:58, Bruno Dumon wrote:
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.
Yes, that's a bit strange, but for the moment it works. I have committed 
it that way.

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.
Good idea.
Joerg


Re: [cforms] Editing existing list of uploads

2004-07-03 Thread Sylvain Wallez
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

--
Sylvain Wallez  Anyware Technologies
http://www.apache.org/~sylvain   http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }