com.arsdigita.cms.ui
Class FileUploadSection

java.lang.Object
  extended bycom.arsdigita.bebop.Completable
      extended bycom.arsdigita.bebop.SimpleComponent
          extended bycom.arsdigita.bebop.FormSection
              extended bycom.arsdigita.cms.ui.FileUploadSection
All Implemented Interfaces:
Cloneable, com.arsdigita.bebop.Component, com.arsdigita.bebop.Container, com.arsdigita.util.Lockable

public class FileUploadSection
extends com.arsdigita.bebop.FormSection

A form section with two widgets: a mime-type selection widget and a file upload widget. The section will attempt to automatically guess the mime type from the filename (if necessary), and return the mime type.

Version:
$Id: //cms/dev/src/com/arsdigita/cms/ui/FileUploadSection.java#13 $
Author:
Stanislav Freidin (sfreidin@arsdigita.com)

Field Summary
static String FILE_UPLOAD
          The file upload widget
static String GUESS_MIME
          Automatically guess the mime type
static String MIME_TYPE
          The mime type widget
static String versionId
           
 
Fields inherited from class com.arsdigita.bebop.FormSection
m_formModel, m_panel
 
Fields inherited from class com.arsdigita.bebop.SimpleComponent
m_attr
 
Fields inherited from interface com.arsdigita.bebop.Component
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE
 
Constructor Summary
FileUploadSection(com.arsdigita.globalization.GlobalizedMessage mimeLabel, String mimePrefix, String defaultMimeType)
          Construct a new FileUploadSection
FileUploadSection(com.arsdigita.globalization.GlobalizedMessage mimeLabel, String mimePrefix, String defaultMimeType, com.arsdigita.bebop.Container panel)
          Construct a new FileUploadSection
FileUploadSection(com.arsdigita.globalization.GlobalizedMessage mimeLabel, String mimePrefix, String defaultMimeType, String parameterPrefix)
          Construct a new FileUploadSection
FileUploadSection(com.arsdigita.globalization.GlobalizedMessage mimeLabel, String mimePrefix, String defaultMimeType, String parameterPrefix, com.arsdigita.bebop.Container panel)
          Construct a new FileUploadSection
FileUploadSection(String mimeLabel, String mimePrefix, String defaultMimeType)
          Deprecated. use the same constructor but with the GlobalizedMessage for the mimeLabel
FileUploadSection(String mimeLabel, String mimePrefix, String defaultMimeType, com.arsdigita.bebop.Container panel)
          Deprecated. use the same constructor but with the GlobalizedMessage for the mimeLabel
FileUploadSection(String mimeLabel, String mimePrefix, String defaultMimeType, String parameterPrefix)
          Deprecated. use the same constructor but with the GlobalizedMessage for the mimeLabel
FileUploadSection(String mimeLabel, String mimePrefix, String defaultMimeType, String parameterPrefix, com.arsdigita.bebop.Container panel)
          Deprecated. use the same constructor but with the GlobalizedMessage for the mimeLabel
 
Method Summary
static void addMimeOptions(com.arsdigita.bebop.form.OptionGroup w, String mimePrefix)
          Add mime-type options to the option group by loading all mime types which match a certain prefix from the database
 File getFile(com.arsdigita.bebop.event.FormSectionEvent e)
          Obtain a File object from the file upload widget.
 String getFileName(com.arsdigita.bebop.event.FormSectionEvent e)
          Obtain a filename from the file upload widget.
 com.arsdigita.bebop.form.FileUpload getFileUploadWidget()
           
 String getFileUploadWidgetName()
           
 com.arsdigita.mimetypes.MimeType getMimeType(com.arsdigita.bebop.event.FormSectionEvent e)
          Try to guess the mime type from the filename, and return it.
 com.arsdigita.bebop.form.SingleSelect getMimeTypeWidget()
           
 String getMimeTypeWidgetName()
           
 String getParameterPrefix()
           
 void setMimeType(com.arsdigita.bebop.event.FormSectionEvent e, String mimeType)
          Set the value for the mime type widget.
 
Methods inherited from class com.arsdigita.bebop.FormSection
add, add, addCancelListener, addInitListener, addProcessListener, addSubmissionListener, addValidationListener, children, contains, createInitListener, createProcessListener, createSubmissionListener, createValidationListener, fireCancel, fireInit, fireProcess, fireSubmitted, fireValidate, forwardInit, forwardProcess, forwardSubmission, forwardValidation, generateXML, get, getModel, getPanel, indexOf, isEmpty, lock, process, register, removeCancelListener, removeInitListener, removeProcessListener, removeSubmissionListener, removeValidationListener, respond, size
 
Methods inherited from class com.arsdigita.bebop.SimpleComponent
clone, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, register, setAttribute, setClassAttr, setIdAttr, setKey, setMetaDataAttribute, setStyleAttr, setVisible
 
Methods inherited from class com.arsdigita.bebop.Completable
addCompletionListener, fireCompletionEvent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.arsdigita.bebop.Component
getClassAttr, getIdAttr, getKey, getStyleAttr, isVisible, register, setClassAttr, setIdAttr, setKey, setStyleAttr, setVisible
 
Methods inherited from interface com.arsdigita.util.Lockable
isLocked
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

MIME_TYPE

public static final String MIME_TYPE
The mime type widget

See Also:
Constant Field Values

FILE_UPLOAD

public static final String FILE_UPLOAD
The file upload widget

See Also:
Constant Field Values

GUESS_MIME

public static final String GUESS_MIME
Automatically guess the mime type

See Also:
Constant Field Values
Constructor Detail

FileUploadSection

public FileUploadSection(com.arsdigita.globalization.GlobalizedMessage mimeLabel,
                         String mimePrefix,
                         String defaultMimeType,
                         com.arsdigita.bebop.Container panel)
Construct a new FileUploadSection

Parameters:
mimeLabel - The label for the mime type widget
mimePrefix - Populate the mime type widget with all mime types that match the prefix. Some of the possible prefixes are "text", "image", "binary", etc.
defaultMimeType - The default mime type that should be assumed if the guessing fails
panel - The panel that is to be used to lay out the components

FileUploadSection

public FileUploadSection(String mimeLabel,
                         String mimePrefix,
                         String defaultMimeType,
                         com.arsdigita.bebop.Container panel)
Deprecated. use the same constructor but with the GlobalizedMessage for the mimeLabel

Construct a new FileUploadSection

Parameters:
mimeLabel - The label for the mime type widget
mimePrefix - Populate the mime type widget with all mime types that match the prefix. Some of the possible prefixes are "text", "image", "binary", etc.
defaultMimeType - The default mime type that should be assumed if the guessing fails
panel - The panel that is to be used to lay out the components

FileUploadSection

public FileUploadSection(String mimeLabel,
                         String mimePrefix,
                         String defaultMimeType,
                         String parameterPrefix,
                         com.arsdigita.bebop.Container panel)
Deprecated. use the same constructor but with the GlobalizedMessage for the mimeLabel

Construct a new FileUploadSection

Parameters:
mimeLabel - The label for the mime type widget
mimePrefix - Populate the mime type widget with all mime types that match the prefix. Some of the possible prefixes are "text", "image", "binary", etc.
defaultMimeType - The default mime type that should be assumed if the guessing fails
parameterPrefix - Prepended to MIME_TYPE and FILE_UPLOAD for parameter names so that more than 1 file upload widgets may be used per form
panel - The panel that is to be used to lay out the components

FileUploadSection

public FileUploadSection(com.arsdigita.globalization.GlobalizedMessage mimeLabel,
                         String mimePrefix,
                         String defaultMimeType,
                         String parameterPrefix,
                         com.arsdigita.bebop.Container panel)
Construct a new FileUploadSection

Parameters:
mimeLabel - The label for the mime type widget
mimePrefix - Populate the mime type widget with all mime types that match the prefix. Some of the possible prefixes are "text", "image", "binary", etc.
defaultMimeType - The default mime type that should be assumed if the guessing fails
parameterPrefix - Prepended to MIME_TYPE and FILE_UPLOAD for parameter names so that more than 1 file upload widgets may be used per form
panel - The panel that is to be used to lay out the components

FileUploadSection

public FileUploadSection(com.arsdigita.globalization.GlobalizedMessage mimeLabel,
                         String mimePrefix,
                         String defaultMimeType,
                         String parameterPrefix)
Construct a new FileUploadSection

Parameters:
mimeLabel - The label for the mime type widget
mimePrefix - Populate the mime type widget with all mime types that match the prefix. Some of the possible prefixes are "text", "image", "binary", etc.
defaultMimeType - The default mime type that should be assumed if the guessing fails
parameterPrefix - Prepended to MIME_TYPE and FILE_UPLOAD for parameter names so that more than 1 file upload widgets may be used per form

FileUploadSection

public FileUploadSection(String mimeLabel,
                         String mimePrefix,
                         String defaultMimeType,
                         String parameterPrefix)
Deprecated. use the same constructor but with the GlobalizedMessage for the mimeLabel

Construct a new FileUploadSection

Parameters:
mimeLabel - The label for the mime type widget
mimePrefix - Populate the mime type widget with all mime types that match the prefix. Some of the possible prefixes are "text", "image", "binary", etc.
defaultMimeType - The default mime type that should be assumed if the guessing fails
parameterPrefix - Prepended to MIME_TYPE and FILE_UPLOAD for parameter names so that more than 1 file upload widgets may be used per form

FileUploadSection

public FileUploadSection(String mimeLabel,
                         String mimePrefix,
                         String defaultMimeType)
Deprecated. use the same constructor but with the GlobalizedMessage for the mimeLabel

Construct a new FileUploadSection

Parameters:
mimeLabel - The label for the mime type widget
mimePrefix - Populate the mime type widget with all mime types that match the prefix. Some of the possible prefixes are "text", "image", "binary", etc.
defaultMimeType - The default mime type that should be assumed if the guessing fails

FileUploadSection

public FileUploadSection(com.arsdigita.globalization.GlobalizedMessage mimeLabel,
                         String mimePrefix,
                         String defaultMimeType)
Construct a new FileUploadSection

Parameters:
mimeLabel - The GlobalizedMessage for the label for the mime type widget
mimePrefix - Populate the mime type widget with all mime types that match the prefix. Some of the possible prefixes are "text", "image", "binary", etc.
defaultMimeType - The default mime type that should be assumed if the guessing fails
Method Detail

getMimeType

public com.arsdigita.mimetypes.MimeType getMimeType(com.arsdigita.bebop.event.FormSectionEvent e)
Try to guess the mime type from the filename, and return it. The parent form should call this method in its process listener. Note that this method may return null if the mime type could not be guessed.

Parameters:
e - The form section event

getFile

public File getFile(com.arsdigita.bebop.event.FormSectionEvent e)
Obtain a File object from the file upload widget. The containing form should call this method in its process listener.

Parameters:
e - The form section event

getFileName

public String getFileName(com.arsdigita.bebop.event.FormSectionEvent e)
Obtain a filename from the file upload widget. The containing form should call this method in its process listener.

Parameters:
e - The form section event

setMimeType

public void setMimeType(com.arsdigita.bebop.event.FormSectionEvent e,
                        String mimeType)
Set the value for the mime type widget. The containing form should call this method in its init listener

Parameters:
e - The form section event
mimeType - The mime type to set, such as "textr/html" or "img/jpeg"

getMimeTypeWidget

public com.arsdigita.bebop.form.SingleSelect getMimeTypeWidget()
Returns:
the mime type widget

getFileUploadWidget

public com.arsdigita.bebop.form.FileUpload getFileUploadWidget()
Returns:
the file upload widget

getParameterPrefix

public String getParameterPrefix()
Returns:
the parameter name prefix

getFileUploadWidgetName

public String getFileUploadWidgetName()
Returns:
the file upload parameter name

getMimeTypeWidgetName

public String getMimeTypeWidgetName()
Returns:
the mime typeparameter name

addMimeOptions

public static void addMimeOptions(com.arsdigita.bebop.form.OptionGroup w,
                                  String mimePrefix)
Add mime-type options to the option group by loading all mime types which match a certain prefix from the database

Parameters:
w - The mime type widget to which options should be added
mimePrefix - Populate the mime type widget with all mime types that match the prefix. Some of the possible prefixes are "text", "image", "binary", etc.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2352 UTC