Quick Start
Add an upload control with a simple progress indicator to your app in 5 minutes.
Here's how to get started:
-
Download
the GWT Uploader release jar file, and add it to your project's class path. E.g.:
lib/org.moxieapps.gwt.uploader-1.1.0.jar
-
Update your GWT module XML configuration file to import the GWT Highcharts module:
<inherits name="org.moxieapps.gwt.uploader.Uploader"/>
-
Within your GWT application, create a "Label" widget that will display the progress:
Label progress = new Label();
-
Create the "Uploader" widget, and set some configuration options using method chaining:
final Uploader uploader = new Uploader()
.setUploadURL("/FileUploadServlet")
.setButtonText("Upload Files")
.setButtonWidth(150)
.setButtonHeight(22);
-
Bind in handlers for the various events you're interested in:
uploader.setUploadProgressHandler(new UploadProgressHandler() {
public boolean onUploadProgress(UploadProgressEvent evt) {
progress.setText(
NumberFormat.getPercentFormat().format(
evt.getBytesComplete() / evt.getBytesTotal()
)
);
return true;
}
}).setFileDialogCompleteHandler(new FileDialogCompleteHandler() {
public boolean onFileDialogComplete(FileDialogCompleteEvent evt) {
progress.setText("Uploading...");
uploader.startUpload();
return true;
}
});
-
Add the widgets to any GWT layout container:
RootPanel.get().add(uploader);
RootPanel.get().add(progress);
- Run the application, click the button to select a file, and upload!