On 02.07.2004 02:52, g[R]eK wrote:

I think clear example will explain everythink:
we have repater like
>
<fd:repeater id="uploads">
  <fd:widgets>
    <fd:field id="name" required="true"/>
    <fd:field id="description" required="true"/>
    <fd:upload id="file" mime-types="text/plain" required="true"/>
  </fd:widgets>
</fd:repeater>

For the first time it will work perfectly, when user hit submit, some binding
will collect data from form and store it in db.
Let's see what is going on when we want to edit stored data.
At the begining binding is carryed out. First problem: we can't bind BLOB ->
upload widget, but as you said it makes no sense, so let's go ahead.
We have some rows filled in with data in the repeater, each row has upload
empty upload widget that suggesting to a user that he has to upload some data.
If he was smart, he did what he want and hit submit button. Then we have some
mess, upload widget is required so it will raise validating errors.

Ah, the @required is the problem. The form does not know that there was already uploaded a file and so the user is forced to upload one.


Another try...
Editing form is different from adding form. It has two repaters:
>
<fd:repeater id="existing_uploads">
  <fd:label>Existing uploads</fd:label>
  <fd:widgets>
    <fd:field id="name" required="true"/>
    <fd:field id="description" required="true"/>
  </fd:widgets>
</fd:repeater>
<fd:repeater id="uploads">
  <fd:label>Uploads</fd:label>
  <fd:widgets>
    <fd:field id="name" required="true"/>
    <fd:field id="description" required="true"/>
    <fd:upload id="file" mime-types="text/plain" required="true"/>
  </fd:widgets>
</fd:repeater>

The second one is for adding new files, the first one is for deleting existing,
but how upload new data to existing file? :-)

Yeah, that's really nasty. Even using two repeaters is not that nice. It might work when doing it the same way the stylesheet does it: offering a button if something has been uploaded. The union widget might help here. Let it depend on a case widget, where the status "upload exists" or not is set. You show either a button or an upload widget. The button switches the status.


setValue() might help but you would need to provide a org.apache.cocoon.servlet.multipart.Part to it.

Ohh, and something else... If problem with upload somehow is solved, we will
have another with handling form submit. If we want do something more than
simple binding, and we want read files we have to read it from form (newly
uploaded) and from db (existing before).

Don't understand.

What a mess, isn't it? :-)

Yes. But the above is at least a valid use case for Upload.setValue(). It might be interesting to know why it was not allowed, maybe I'm missing some security reasons at the moment.


Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to