|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.itmill.toolkit.ui.AbstractComponent
com.itmill.toolkit.ui.Upload
public class Upload
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().
Nested Class Summary | |
---|---|
class |
Upload.FailedEvent
Upload.Interrupted event is sent when the upload is received, but the reception is interrupted for some reason. |
static interface |
Upload.FailedListener
Receives events when the uploads are finished, but unsuccessful. |
class |
Upload.FinishedEvent
Upload.Received event is sent when the upload receives a file, regardless of whether the reception was successful or failed. |
static interface |
Upload.FinishedListener
Receives the events when the uploads are ready. |
class |
Upload.NoInputStreamEvent
FailedEvent that indicates that an input stream could not be obtained. |
class |
Upload.NoOutputStreamEvent
FailedEvent that indicates that an output stream could not be obtained. |
static interface |
Upload.ProgressListener
ProgressListener receives events to track progress of upload. |
static interface |
Upload.Receiver
Interface that must be implemented by the upload receivers to provide the Upload component an output stream to write the uploaded data. |
class |
Upload.StartedEvent
Upload.Started event is sent when the upload is started to received. |
static interface |
Upload.StartedListener
Receives the events when the upload starts. |
class |
Upload.SucceededEvent
Upload.Success event is sent when the upload is received successfully. |
static interface |
Upload.SucceededListener
Receives events when the uploads are successfully finished. |
Nested classes/interfaces inherited from class com.itmill.toolkit.ui.AbstractComponent |
---|
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler |
Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Component |
---|
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener |
Nested classes/interfaces inherited from interface com.itmill.toolkit.terminal.Paintable |
---|
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener |
Field Summary |
---|
Fields inherited from interface com.itmill.toolkit.terminal.Sizeable |
---|
SIZE_UNDEFINED, UNIT_SYMBOLS, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS |
Constructor Summary | |
---|---|
Upload(String caption,
Upload.Receiver uploadReceiver)
Creates a new instance of Upload that redirects the uploaded data to stream given by the Receiver. |
Method Summary | |
---|---|
void |
addListener(Upload.FailedListener listener)
Adds the upload interrupted event listener. |
void |
addListener(Upload.FinishedListener listener)
Adds the upload received event listener. |
void |
addListener(Upload.ProgressListener listener)
Adds the upload success event listener. |
void |
addListener(Upload.StartedListener listener)
Adds the upload started event listener. |
void |
addListener(Upload.SucceededListener listener)
Adds the upload success event listener. |
void |
attach()
Notifies the component that it is connected to an application. |
void |
changeVariables(Object source,
Map variables)
Invoked when the value of a variable has changed. |
void |
endUpload()
Go into state where new uploading can begin. |
protected void |
fireNoInputStream(String filename,
String MIMEType,
long length)
|
protected void |
fireNoOutputStream(String filename,
String MIMEType,
long length)
|
protected void |
fireStarted(String filename,
String MIMEType)
Emit upload received event. |
protected void |
fireUpdateProgress(long totalBytes,
long contentLength)
Emits the progress event. |
protected void |
fireUploadInterrupted(String filename,
String MIMEType,
long length)
Emits the upload failed event. |
protected void |
fireUploadInterrupted(String filename,
String MIMEType,
long length,
Exception e)
|
protected void |
fireUploadReceived(String filename,
String MIMEType,
long length)
Emit upload finished event. |
protected void |
fireUploadSuccess(String filename,
String MIMEType,
long length)
Emits the upload success event. |
void |
focus()
Sets the focus to this component. |
String |
getButtonCaption()
|
long |
getBytesRead()
Gets read bytes of the file currently being uploaded. |
Upload.ProgressListener |
getProgressListener()
Deprecated. Replaced with addListener/removeListener |
Upload.Receiver |
getReceiver()
Returns the current receiver. |
int |
getTabIndex()
Gets the Tabulator index of this Focusable component. |
String |
getTag()
Gets the component type. |
long |
getUploadSize()
Returns size of file currently being uploaded. |
boolean |
isUploading()
|
void |
paintContent(PaintTarget target)
Paints the content of this component. |
void |
receiveUpload(UploadStream upload)
This method is called by terminal when upload is received. |
void |
removeListener(Upload.FailedListener listener)
Removes the upload interrupted event listener. |
void |
removeListener(Upload.FinishedListener listener)
Removes the upload received event listener. |
void |
removeListener(Upload.ProgressListener listener)
Removes the upload success event listener. |
void |
removeListener(Upload.StartedListener listener)
Removes the upload started event listener. |
void |
removeListener(Upload.SucceededListener listener)
Removes the upload success event listener. |
void |
setButtonCaption(String buttonCaption)
File uploads usually have button that starts actual upload progress. |
void |
setProgressListener(Upload.ProgressListener progressListener)
Deprecated. Use addListener(ProgressListener) instead. |
void |
setReceiver(Upload.Receiver receiver)
Sets the receiver. |
void |
setTabIndex(int tabIndex)
Sets the Tabulator index of this Focusable component. |
void |
setUploadSize(long contentLength)
Sets the size of the file currently being uploaded. |
void |
startUpload()
Go into upload state. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.itmill.toolkit.ui.Component |
---|
addListener, addStyleName, childRequestedRepaint, detach, getApplication, getCaption, getIcon, getLocale, getParent, getStyleName, getWindow, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setParent, setReadOnly, setStyleName, setVisible |
Methods inherited from interface com.itmill.toolkit.terminal.Paintable |
---|
addListener, getDebugId, paint, removeListener, requestRepaint, requestRepaintRequests, setDebugId |
Methods inherited from interface com.itmill.toolkit.terminal.VariableOwner |
---|
isImmediate |
Methods inherited from interface com.itmill.toolkit.terminal.Sizeable |
---|
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeight, setHeightUnits, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidth, setWidthUnits |
Constructor Detail |
---|
public Upload(String caption, Upload.Receiver uploadReceiver)
caption
- Normal component caption. You can set the caption of the
upload submit button with setButtonCaption().uploadReceiver
- Receiver to call to retrieve output stream when upload starts.Method Detail |
---|
public String getTag()
getTag
in class AbstractComponent
public void receiveUpload(UploadStream upload)
upload
- public void changeVariables(Object source, Map variables)
changeVariables
in interface VariableOwner
changeVariables
in class AbstractComponent
source
- the Source of the variable change. This is the origin of the
event. For example in Web Adapter this is the request.variables
- the Mapping from variable names to new variable values.AbstractComponent.changeVariables(java.lang.Object,
java.util.Map)
public void paintContent(PaintTarget target) throws PaintException
paintContent
in class AbstractComponent
target
- Target to paint the content on.
PaintException
- if the paint operation failed.public void addListener(Upload.StartedListener listener)
listener
- the Listener to be added.public void removeListener(Upload.StartedListener listener)
listener
- the Listener to be removed.public void addListener(Upload.FinishedListener listener)
listener
- the Listener to be added.public void removeListener(Upload.FinishedListener listener)
listener
- the Listener to be removed.public void addListener(Upload.FailedListener listener)
listener
- the Listener to be added.public void removeListener(Upload.FailedListener listener)
listener
- the Listener to be removed.public void addListener(Upload.SucceededListener listener)
listener
- the Listener to be added.public void removeListener(Upload.SucceededListener listener)
listener
- the Listener to be removed.public void addListener(Upload.ProgressListener listener)
listener
- the Listener to be added.public void removeListener(Upload.ProgressListener listener)
listener
- the Listener to be removed.protected void fireStarted(String filename, String MIMEType)
filename
- MIMEType
- length
- protected void fireUploadReceived(String filename, String MIMEType, long length)
filename
- MIMEType
- length
- protected void fireUploadInterrupted(String filename, String MIMEType, long length)
filename
- MIMEType
- length
- protected void fireNoInputStream(String filename, String MIMEType, long length)
protected void fireNoOutputStream(String filename, String MIMEType, long length)
protected void fireUploadInterrupted(String filename, String MIMEType, long length, Exception e)
protected void fireUploadSuccess(String filename, String MIMEType, long length)
filename
- MIMEType
- length
- protected void fireUpdateProgress(long totalBytes, long contentLength)
totalBytes
- bytes received so farcontentLength
- actual size of the file being uploaded, if knownpublic Upload.Receiver getReceiver()
public void setReceiver(Upload.Receiver receiver)
receiver
- the receiver to set.public void focus()
Component.Focusable
focus
in interface Component.Focusable
public int getTabIndex()
getTabIndex
in interface Component.Focusable
Component.Focusable.getTabIndex()
public void setTabIndex(int tabIndex)
setTabIndex
in interface Component.Focusable
tabIndex
- the tab order of this component. Indexes usually start
from 1. Negative value means that field is not wanted to
tabbing sequence.Component.Focusable.setTabIndex(int)
public void setUploadSize(long contentLength)
contentLength
- public void startUpload()
public void endUpload()
public boolean isUploading()
public long getBytesRead()
public long getUploadSize()
@Deprecated public void setProgressListener(Upload.ProgressListener progressListener)
progressListener
- @Deprecated public Upload.ProgressListener getProgressListener()
public String getButtonCaption()
public void setButtonCaption(String buttonCaption)
buttonCaption
- text for uploads button.public void attach()
attach
in interface Component
attach
in class AbstractComponent
Component.attach()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |