Apache » Cocoon »

  Cocoon Forms
      1.0
   homepage

Cocoon Forms 1.0

Upload widget

Concept

This widget allows to upload files by using Cocoon's file upload features. For this reason, this widget won't function properly unless enable-uploads is set to true in WEB-INF/web.xml.

Also, don't forget to put the enctype attribute as multipart/form-data in the ft:form-template element, inside the template file.

To retrieve the uploaded data, simply use the getValue method of the widget, which will in this case return an object of the following type:

org.apache.cocoon.servlet.multipart.Part

The uploaded data will be automatically cleaned up when the upload widget instance object is finialized by the JVM.

Definition

<fd:upload id="..." mime-types="text/plain, text/xml" required="true|false" state="...">
  <fd:label>...</fd:label>
  <fd:help>...</fd:help>
  <fd:hint>...</fd:hint>
  <fd:validation>
    [...]
  </fd:validation>
  <fd:on-create>
    [...]
  </fd:on-create>
  <fd:attributes>
    <fd:attribute name="..." value="..."/>
  </fd:attributes>
</fd:upload>

The optional mime-types attribute allows to specify a comma-separated list of mime-types which are accepted. The widget will be invalid if the uploaded type isn't of one of the specified content types.

Template

An upload widget is inserted in a template using the ft:widget tag:

<ft:widget id="..."/>

Styling (default HTML XSL)

The upload widget is rendered as a default HTML upload control.

Errors and Improvements? If you see any errors or potential improvements in this document please help us: View, Edit or comment on the latest development version (registration required).