org.olat.core.gui.components.form.flexible.elements
Interface FileElement

All Superinterfaces:
FormBaseComponentIdProvider, FormItem, FormMultipartItem
All Known Implementing Classes:
FileElementImpl

public interface FileElement
extends FormMultipartItem

Description:

The FileElement represents a file within a flexi form. It offers a read only view of files and an upload view.

Initial Date: 08.12.2008

Author:
Florian Gnaegi, frentix GmbH, http://www.frentix.com

Field Summary
static int UPLOAD_ONE_MEGABYTE
           
static int UPLOAD_UNLIMITED
           
 
Fields inherited from interface org.olat.core.gui.components.form.flexible.FormItem
ERRORC, EXAMPLEC, LABELC
 
Fields inherited from interface org.olat.core.gui.components.form.flexible.FormBaseComponentIdProvider
DISPPREFIX
 
Method Summary
 java.io.File getInitialFile()
          Get the initial file value
 java.util.Set<java.lang.String> getMimeTypeLimitations()
          Get the set of the mime types limitation
 java.io.File getUploadFile()
          Use the upload file only for temporary checks on the file.
 java.lang.String getUploadFileName()
           
 java.io.InputStream getUploadInputStream()
          Get the input stream of the uploaded file to copy it to some other place
 java.lang.String getUploadMimeType()
           
 long getUploadSize()
          Get the size of the uploaded file
 boolean isUploadSuccess()
           
 void limitToMimeType(java.util.Set<java.lang.String> mimeTypes, java.lang.String i18nErrKey, java.lang.String[] i18nArgs)
          Set a mime type limitation on which files are allowed in the upload process.
 java.io.File moveUploadFileTo(java.io.File destinationDir)
          Move the uploaded file from the temporary location to the given destination directory.
 void setInitialFile(java.io.File initialFile)
          Set an initial value for the file element.
 void setMandatory(boolean mandatory, java.lang.String i18nErrKey)
          Set this form element mandatory.
 void setMaxUploadSizeKB(int maxFileSizeKB, java.lang.String i18nErrKey, java.lang.String[] i18nArgs)
          Set the KB that are allowed in the file upload.
 
Methods inherited from interface org.olat.core.gui.components.form.flexible.FormMultipartItem
getMaxUploadSizeKB
 
Methods inherited from interface org.olat.core.gui.components.form.flexible.FormItem
addActionListener, clearError, doDispatchFormRequest, evalFormRequest, getAction, getActionListenersFor, getComponent, getErrorC, getErrorText, getExampleC, getExampleText, getLabelC, getLabelText, getName, getRootForm, getTranslator, getUserObject, hasError, hasExample, hasFocus, hasLabel, isEnabled, isMandatory, isVisible, reset, setEnabled, setErrorComponent, setErrorKey, setExampleKey, setFocus, setLabel, setLabelComponent, setMandatory, setRootForm, setTranslator, setUserObject, setVisible, showError, showExample, showLabel, validate
 
Methods inherited from interface org.olat.core.gui.components.form.flexible.FormBaseComponentIdProvider
getFormDispatchId
 

Field Detail

UPLOAD_ONE_MEGABYTE

static final int UPLOAD_ONE_MEGABYTE
See Also:
Constant Field Values

UPLOAD_UNLIMITED

static final int UPLOAD_UNLIMITED
See Also:
Constant Field Values
Method Detail

setInitialFile

void setInitialFile(java.io.File initialFile)
Set an initial value for the file element. Optional. Use this to preload your file element with a previously submitted file.

Parameters:
initialFile -

getInitialFile

java.io.File getInitialFile()
Get the initial file value

Returns:
the file or NULL if not set

setMaxUploadSizeKB

void setMaxUploadSizeKB(int maxFileSizeKB,
                        java.lang.String i18nErrKey,
                        java.lang.String[] i18nArgs)
Set the KB that are allowed in the file upload. In case the user uploads too much, the error with the given key will be displayed.
Use UPLOAD_UNLIMITED to set no limit.

Parameters:
maxFileSizeKB - max file size in KB
i18nErrKey - i18n key used in case user uploaded to big file
i18nArgs - optional arguments for thei18nErrKey

limitToMimeType

void limitToMimeType(java.util.Set<java.lang.String> mimeTypes,
                     java.lang.String i18nErrKey,
                     java.lang.String[] i18nArgs)
Set a mime type limitation on which files are allowed in the upload process. Wildcards like image/* are also allowed.

Parameters:
mimeTypes -
i18nErrKey - i18n key used in case user uploaded wrong files
i18nArgs - optional arguments for thei18nErrKey

getMimeTypeLimitations

java.util.Set<java.lang.String> getMimeTypeLimitations()
Get the set of the mime types limitation

Returns:
Set containing mime types. Can be empty but is never NULL.

setMandatory

void setMandatory(boolean mandatory,
                  java.lang.String i18nErrKey)
Set this form element mandatory.

Parameters:
mandatory - true: is mandatory; false: is optional
i18nErrKey - i18n key used in case user did not upload something

isUploadSuccess

boolean isUploadSuccess()
Returns:
true: file has been uploaded; false: file has not been uploaded

getUploadSize

long getUploadSize()
Get the size of the uploaded file

Returns:

getUploadFileName

java.lang.String getUploadFileName()
Returns:
The filename of the uploaded file

getUploadMimeType

java.lang.String getUploadMimeType()
Returns:
The mime type of the uploaded file

getUploadFile

java.io.File getUploadFile()
Use the upload file only for temporary checks on the file. Use the moveUploadFileTo() to move the file to the final destination. The temp file will be deleted on form disposal.

Returns:
A reference to the uploaded file

getUploadInputStream

java.io.InputStream getUploadInputStream()
Get the input stream of the uploaded file to copy it to some other place

Returns:

moveUploadFileTo

java.io.File moveUploadFileTo(java.io.File destinationDir)
Move the uploaded file from the temporary location to the given destination directory.

If in the destination a file with the given name does already exist, rename the file accordingly

Parameters:
destinationDir -
Returns:
A reference to the moved file or NULL if file could not be moved