(Quick Reference)

file

Purpose

Adds a DefaultUploadField to the parent container.

Examples

// No filename stored
<v:form bean="${bookInstance}">
  <v:file name="file">File</v:file>
</v:form>

// Filename stored in separate field <v:form bean="${bookInstance}"> <v:text name="filename" var="filenameField">File Name</v:text> <v:file name="file" filename="${bookInstance.filename}" onupload="${{evt->filenameField = evt.fileName}}">File</v:file> </v:form>

// Standalone <v:file>My File Field</v:file>

Description

The file tag is a special type of field tag, where the field component is a DefaultUploadField

This is a subclass of the UploadField class in the easyuploads Vaadin Addon.

The underlying property type should be byte[] or Byte[].

The field provides a download link in readOnly mode, and a download link, upload button (with progress bar) and delete button in edit mode.

Note that this field stores the file bytes directly in the data source. It is therefore not possible to store the filename in the same field. You can use the onupload and filename attributes to read and write the filename using a separate field, as in the above example.

Body

  • Contains the caption for the field

Attributes

Specific
  • name (optional) The property name of the field
  • caption (optional) The caption of the field. Overrides the body content.
  • filename (optional) The default filename to use for the download link. Note that when a file has just been uploaded, its original filename is displayed. This is lost, however, after the file is saved to the dataSource.
  • onupload (optional) Either a SucceededListener or a Closure that takes a SucceededEvent parameter

General
  • var (optional) Uses Grails's set tag to set the value of the specified variable to be this component.
  • class (optional) The CSS class name to add to the component using the addStyleName() method
  • sizeUndefined (optional) Calls setSizeUndefined() on the component. (Attribute value is ignored)
  • sizeFull (optional) Calls setSizeFull() on the component. (Attribute value is ignored)

See Vaadin DefaultUploadField API docs for full list of allowed attributes.