Class Upload
-
- All Implemented Interfaces:
ConnectorEventListener,ContextClickEvent.ContextClickNotifier,MethodEventSource,SerializableEventListener,ClientConnector,Sizeable,VariableOwner,com.vaadin.shared.Connector,Component,Component.Focusable,LegacyComponent,Serializable,EventListener
@Deprecated public class Upload extends AbstractLegacyComponent implements Component.Focusable, LegacyComponent
Deprecated.As of 8.0 replaced byUploadthat is by default in immediate mode.Component for uploading files from client to server.The visible component consists of a file name input box and a browse button and an upload submit button to start uploading.
The Upload component needs a java.io.OutputStream to write the uploaded data. You need to implement the Upload.Receiver interface and return the output stream in the receiveUpload() method.
You can get an event regarding starting (StartedEvent), progress (ProgressEvent), and finishing (FinishedEvent) of upload by implementing StartedListener, ProgressListener, and FinishedListener, respectively. The FinishedListener is called for both failed and succeeded uploads. If you wish to separate between these two cases, you can use SucceededListener (SucceededEvenet) and FailedListener (FailedEvent).
The upload component does not itself show upload progress, but you can use the ProgressIndicator for providing progress feedback by implementing ProgressListener and updating the indicator in updateProgress().
Setting upload component immediate initiates the upload as soon as a file is selected, instead of the common pattern of file selection field and upload button.
Note! Because of browser dependent implementations of <input type="file"> element, setting size for Upload component is not supported. For some browsers setting size may work to some extend.
- Since:
- 3.0
- Author:
- Vaadin Ltd.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUpload.ChangeEventDeprecated.static interfaceUpload.ChangeListenerDeprecated.static classUpload.FailedEventDeprecated.static interfaceUpload.FailedListenerDeprecated.static classUpload.FinishedEventDeprecated.static interfaceUpload.FinishedListenerDeprecated.static classUpload.NoInputStreamEventDeprecated.static classUpload.NoOutputStreamEventDeprecated.static interfaceUpload.ProgressListenerDeprecated.static interfaceUpload.ReceiverDeprecated.static classUpload.StartedEventDeprecated.static interfaceUpload.StartedListenerDeprecated.static classUpload.SucceededEventDeprecated.static interfaceUpload.SucceededListenerDeprecated.-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
-
Constructor Summary
Constructors Constructor Description Upload()Deprecated.Creates a new instance of Upload.Upload(String caption, Upload.Receiver uploadReceiver)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddChangeListener(Upload.ChangeListener listener)Deprecated.Adds a filename change event listener.voidaddFailedListener(Upload.FailedListener listener)Deprecated.Adds the upload interrupted event listener.voidaddFinishedListener(Upload.FinishedListener listener)Deprecated.Adds the upload received event listener.voidaddListener(Upload.FailedListener listener)Deprecated.As of 7.0, replaced byaddFailedListener(FailedListener)voidaddListener(Upload.FinishedListener listener)Deprecated.As of 7.0, replaced byaddFinishedListener(FinishedListener)voidaddListener(Upload.ProgressListener listener)Deprecated.As of 7.0, replaced byaddProgressListener(ProgressListener)voidaddListener(Upload.StartedListener listener)Deprecated.As of 7.0, replaced byaddStartedListener(StartedListener)voidaddListener(Upload.SucceededListener listener)Deprecated.As of 7.0, replaced byaddSucceededListener(SucceededListener)voidaddProgressListener(Upload.ProgressListener listener)Deprecated.Adds the upload progress event listener.voidaddStartedListener(Upload.StartedListener listener)Deprecated.Adds the upload started event listener.voidaddSucceededListener(Upload.SucceededListener listener)Deprecated.Adds the upload success event listener.voidchangeVariables(Object source, Map<String,Object> variables)Deprecated.protected voidfireNoInputStream(String filename, String mimeType, long length)Deprecated.protected voidfireNoOutputStream(String filename, String mimeType, long length)Deprecated.protected voidfireStarted(String filename, String mimeType)Deprecated.Emit upload received event.protected voidfireUpdateProgress(long totalBytes, long contentLength)Deprecated.Emits the progress event.protected voidfireUploadInterrupted(String filename, String mimeType, long length)Deprecated.Emits the upload failed event.protected voidfireUploadInterrupted(String filename, String mimeType, long length, Exception e)Deprecated.protected voidfireUploadSuccess(String filename, String mimeType, long length)Deprecated.Emits the upload success event.voidfocus()Deprecated.StringgetButtonCaption()Deprecated.longgetBytesRead()Deprecated.Gets read bytes of the file currently being uploaded.Collection<?>getListeners(Class<?> eventType)Deprecated.Upload.ReceivergetReceiver()Deprecated.Returns the current receiver.protected UploadStategetState()Deprecated.protected StreamVariablegetStreamVariable()Deprecated.intgetTabIndex()Deprecated.Gets the Tabulator index of this Focusable component.longgetUploadSize()Deprecated.Returns size of file currently being uploaded.voidinterruptUpload()Deprecated.Interrupts the upload currently being received.booleanisImmediate()Deprecated.Returns the immediate mode of the component.booleanisUploading()Deprecated.voidmarkAsDirty()Deprecated.voidpaintContent(PaintTarget target)Deprecated.Paints the content of this component.voidremoveChangeListener(Upload.ChangeListener listener)Deprecated.Removes a filename change event listener.voidremoveFailedListener(Upload.FailedListener listener)Deprecated.Removes the upload interrupted event listener.voidremoveFinishedListener(Upload.FinishedListener listener)Deprecated.Removes the upload received event listener.voidremoveListener(Upload.FailedListener listener)Deprecated.As of 7.0, replaced byremoveFailedListener(FailedListener)voidremoveListener(Upload.FinishedListener listener)Deprecated.As of 7.0, replaced byremoveFinishedListener(FinishedListener)voidremoveListener(Upload.ProgressListener listener)Deprecated.As of 7.0, replaced byremoveProgressListener(ProgressListener)voidremoveListener(Upload.StartedListener listener)Deprecated.As of 7.0, replaced byremoveStartedListener(StartedListener)voidremoveListener(Upload.SucceededListener listener)Deprecated.As of 7.0, replaced byremoveSucceededListener(SucceededListener)voidremoveProgressListener(Upload.ProgressListener listener)Deprecated.Removes the upload progress event listener.voidremoveStartedListener(Upload.StartedListener listener)Deprecated.Removes the upload started event listener.voidremoveSucceededListener(Upload.SucceededListener listener)Deprecated.Removes the upload success event listener.voidsetButtonCaption(String buttonCaption)Deprecated.In addition to the actual file chooser, upload components have button that starts actual upload progress.voidsetReceiver(Upload.Receiver receiver)Deprecated.Sets the receiver.voidsetTabIndex(int tabIndex)Deprecated.Sets the Tabulator index of this Focusable component.voidstartUpload()Deprecated.Go into upload state.voidsubmitUpload()Deprecated.Forces the upload the send selected file to the server.-
Methods inherited from class com.vaadin.v7.ui.AbstractLegacyComponent
beforeClientResponse, getExplicitImmediateValue, getState, isReadOnly, readDesign, setImmediate, setReadOnly, writeDesign
-
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getCustomAttributes, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isRequiredIndicatorVisible, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, readDesign, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible, writeDesign
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from interface com.vaadin.server.VariableOwner
isEnabled
-
-
-
-
Constructor Detail
-
Upload
public Upload()
Deprecated.Creates a new instance of Upload. The receiver must be set before performing an upload.
-
Upload
public Upload(String caption, Upload.Receiver uploadReceiver)
Deprecated.
-
-
Method Detail
-
changeVariables
public void changeVariables(Object source, Map<String,Object> variables)
Deprecated.- Specified by:
changeVariablesin interfaceVariableOwner
-
paintContent
public void paintContent(PaintTarget target) throws PaintException
Deprecated.Paints the content of this component.- Specified by:
paintContentin interfaceLegacyComponent- Parameters:
target- Target to paint the content on.- Throws:
PaintException- if the paint operation failed.
-
addStartedListener
public void addStartedListener(Upload.StartedListener listener)
Deprecated.Adds the upload started event listener.- Parameters:
listener- the Listener to be added, not null
-
addListener
@Deprecated public void addListener(Upload.StartedListener listener)
Deprecated.As of 7.0, replaced byaddStartedListener(StartedListener)
-
removeStartedListener
public void removeStartedListener(Upload.StartedListener listener)
Deprecated.Removes the upload started event listener.- Parameters:
listener- the Listener to be removed.
-
removeListener
@Deprecated public void removeListener(Upload.StartedListener listener)
Deprecated.As of 7.0, replaced byremoveStartedListener(StartedListener)
-
addFinishedListener
public void addFinishedListener(Upload.FinishedListener listener)
Deprecated.Adds the upload received event listener.- Parameters:
listener- the Listener to be added, not null
-
addListener
@Deprecated public void addListener(Upload.FinishedListener listener)
Deprecated.As of 7.0, replaced byaddFinishedListener(FinishedListener)
-
removeFinishedListener
public void removeFinishedListener(Upload.FinishedListener listener)
Deprecated.Removes the upload received event listener.- Parameters:
listener- the Listener to be removed.
-
removeListener
@Deprecated public void removeListener(Upload.FinishedListener listener)
Deprecated.As of 7.0, replaced byremoveFinishedListener(FinishedListener)
-
addFailedListener
public void addFailedListener(Upload.FailedListener listener)
Deprecated.Adds the upload interrupted event listener.- Parameters:
listener- the Listener to be added, not null
-
addListener
@Deprecated public void addListener(Upload.FailedListener listener)
Deprecated.As of 7.0, replaced byaddFailedListener(FailedListener)
-
removeFailedListener
public void removeFailedListener(Upload.FailedListener listener)
Deprecated.Removes the upload interrupted event listener.- Parameters:
listener- the Listener to be removed.
-
removeListener
@Deprecated public void removeListener(Upload.FailedListener listener)
Deprecated.As of 7.0, replaced byremoveFailedListener(FailedListener)
-
addSucceededListener
public void addSucceededListener(Upload.SucceededListener listener)
Deprecated.Adds the upload success event listener.- Parameters:
listener- the Listener to be added, not null
-
addListener
@Deprecated public void addListener(Upload.SucceededListener listener)
Deprecated.As of 7.0, replaced byaddSucceededListener(SucceededListener)
-
removeSucceededListener
public void removeSucceededListener(Upload.SucceededListener listener)
Deprecated.Removes the upload success event listener.- Parameters:
listener- the Listener to be removed.
-
removeListener
@Deprecated public void removeListener(Upload.SucceededListener listener)
Deprecated.As of 7.0, replaced byremoveSucceededListener(SucceededListener)
-
addProgressListener
public void addProgressListener(Upload.ProgressListener listener)
Deprecated.Adds the upload progress event listener.- Parameters:
listener- the progress listener to be added
-
addListener
@Deprecated public void addListener(Upload.ProgressListener listener)
Deprecated.As of 7.0, replaced byaddProgressListener(ProgressListener)
-
removeProgressListener
public void removeProgressListener(Upload.ProgressListener listener)
Deprecated.Removes the upload progress event listener.- Parameters:
listener- the progress listener to be removed
-
addChangeListener
public void addChangeListener(Upload.ChangeListener listener)
Deprecated.Adds a filename change event listener.- Parameters:
listener- the Listener to add, not null
-
removeChangeListener
public void removeChangeListener(Upload.ChangeListener listener)
Deprecated.Removes a filename change event listener.- Parameters:
listener- the listener to be removed
-
removeListener
@Deprecated public void removeListener(Upload.ProgressListener listener)
Deprecated.As of 7.0, replaced byremoveProgressListener(ProgressListener)
-
fireStarted
protected void fireStarted(String filename, String mimeType)
Deprecated.Emit upload received event.- Parameters:
filename-mimeType-
-
fireUploadInterrupted
protected void fireUploadInterrupted(String filename, String mimeType, long length)
Deprecated.Emits the upload failed event.- Parameters:
filename-mimeType-length-
-
fireNoInputStream
protected void fireNoInputStream(String filename, String mimeType, long length)
Deprecated.
-
fireNoOutputStream
protected void fireNoOutputStream(String filename, String mimeType, long length)
Deprecated.
-
fireUploadInterrupted
protected void fireUploadInterrupted(String filename, String mimeType, long length, Exception e)
Deprecated.
-
fireUploadSuccess
protected void fireUploadSuccess(String filename, String mimeType, long length)
Deprecated.Emits the upload success event.- Parameters:
filename-mimeType-length-
-
fireUpdateProgress
protected void fireUpdateProgress(long totalBytes, long contentLength)Deprecated.Emits the progress event.- Parameters:
totalBytes- bytes received so farcontentLength- actual size of the file being uploaded, if known
-
getReceiver
public Upload.Receiver getReceiver()
Deprecated.Returns the current receiver.- Returns:
- the StreamVariable.
-
setReceiver
public void setReceiver(Upload.Receiver receiver)
Deprecated.Sets the receiver.- Parameters:
receiver- the receiver to set.
-
focus
public void focus()
Deprecated.- Specified by:
focusin interfaceComponent.Focusable- Overrides:
focusin classAbstractComponent
-
getTabIndex
public int getTabIndex()
Deprecated.Gets the Tabulator index of this Focusable component.- Specified by:
getTabIndexin interfaceComponent.Focusable- See Also:
Component.Focusable.getTabIndex()
-
setTabIndex
public void setTabIndex(int tabIndex)
Deprecated.Sets the Tabulator index of this Focusable component.- Specified by:
setTabIndexin interfaceComponent.Focusable- See Also:
Component.Focusable.setTabIndex(int)
-
startUpload
public void startUpload()
Deprecated.Go into upload state. This is to prevent double uploading on same component. Warning: this is an internal method used by the framework and should not be used by user of the Upload component. Using it results in the Upload component going in wrong state and not working. It is currently public because it is used by another class.
-
interruptUpload
public void interruptUpload()
Deprecated.Interrupts the upload currently being received. The interruption will be done by the receiving thread so this method will return immediately and the actual interrupt will happen a bit later.
-
isUploading
public boolean isUploading()
Deprecated.
-
getBytesRead
public long getBytesRead()
Deprecated.Gets read bytes of the file currently being uploaded.- Returns:
- bytes
-
getUploadSize
public long getUploadSize()
Deprecated.Returns size of file currently being uploaded. Value sane only during upload.- Returns:
- size in bytes
-
getButtonCaption
public String getButtonCaption()
Deprecated.- Returns:
- String to be rendered into button that fires uploading
-
setButtonCaption
public void setButtonCaption(String buttonCaption)
Deprecated.In addition to the actual file chooser, upload components have button that starts actual upload progress. This method is used to set text in that button.In case the button text is set to null, the button is hidden. In this case developer must explicitly initiate the upload process with
submitUpload().In case the Upload is used in immediate mode using
AbstractLegacyComponent.setImmediate(boolean), the file choose (html input with type "file") is hidden and only the button with this text is shown.Note the string given is set as is to the button. HTML formatting is not stripped. Be sure to properly validate your value according to your needs.
- Parameters:
buttonCaption- text for upload components button.
-
submitUpload
public void submitUpload()
Deprecated.Forces the upload the send selected file to the server.In case developer wants to use this feature, he/she will most probably want to hide the uploads internal submit button by setting its caption to null with
setButtonCaption(String)method.Note, that the upload runs asynchronous. Developer should use normal upload listeners to trac the process of upload. If the field is empty uploaded the file name will be empty string and file length 0 in the upload finished event.
Also note, that the developer should not remove or modify the upload in the same user transaction where the upload submit is requested. The upload may safely be hidden or removed once the upload started event is fired.
-
markAsDirty
public void markAsDirty()
Deprecated.- Specified by:
markAsDirtyin interfaceClientConnector- Specified by:
markAsDirtyin interfaceLegacyComponent- Overrides:
markAsDirtyin classAbstractClientConnector
-
getStreamVariable
protected StreamVariable getStreamVariable()
Deprecated.
-
getListeners
public Collection<?> getListeners(Class<?> eventType)
Deprecated.- Overrides:
getListenersin classAbstractClientConnector
-
isImmediate
public boolean isImmediate()
Deprecated.Returns the immediate mode of the component.An immediate mode Upload component displays the browser file choosing button immediately, whereas a non-immediate upload only shows a Vaadin button.
The default mode of an Upload component is non-immediate.
- Overrides:
isImmediatein classAbstractLegacyComponent- Returns:
- true if the component is in immediate mode, false if the component if not in immediate mode
-
getState
protected UploadState getState()
Deprecated.- Overrides:
getStatein classAbstractLegacyComponent
-
-