Book Image

ExtGWT Rich Internet Application Cookbook

By : Odili Charles Opute , Oded Nissan
Book Image

ExtGWT Rich Internet Application Cookbook

By: Odili Charles Opute , Oded Nissan

Overview of this book

<p>Get ready to build the next generation Gmail, Facebook, or Meebo, with HTML5 and Server Push, taking advantage of the power and versatility of Java with ExtGWT. Sencha Ext GWT takes GWT to the next level, giving you high-performance widgets, feature-rich templates and layouts, advanced charting, data loaders and stores,&nbsp; accessibility, and much more.<br /><br /><i>ExtGWT Rich Internet Application Cookbook will teach you to quickly build&nbsp; stunning functionality into your own apps with ExtGWT</i>.<br /><br />This is a catalog of practical solutions to get your ExtGWT web app up and running in no time, with tips for persistence and best practices. You begin by playing with panels, windows, and tabs, to learn the essentials. Next, you engage yourself with forms, buttons, toolbars and menus to build on further. Dealing with the UI and the trees will follow to help you make stunning user interfaces. Then you will be taught to work with Listview, Views, and Gridpanels, the more complex problems. The book will then deal with charts, visualization, and drag and drop to take you to the next level. Finally, you will wind up with serialization, persistence, and custom theming. Now, you are an expert!</p>
Table of Contents (22 chapters)
ExtGWT Rich Internet Application Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Event Handling — Making Those GUIs Do Something
Jakarta Commons-FileUpload

Tracking upload progress


If you expect really large file uploads, then it would be nice to report to your users, how much is already received. Even HTML pages allow implementing a progress bar by returning a multipart/replace response, or something like that. Tracking the upload progress may be done by supplying a ProgressListener.

ProgressListener is called quite frequently, depending on the servlet engine and other environment factors it may be called for any network packet. In other words, your ProgressListener may become a performance problem! A typical solution might be to reduce the activity of ProgressListener to only emit a message if the number of megabytes has changed beyond a range. The following example shows a ProgressListener which implements this solution. We will probably want to communicate the progress to the progress bar on the client. The Real-time server push recipe in Chapter 11, Advanced Tips, can be used as a starting point for implementing pushing updates to the client.

/Create a progress listener
ProgressListener progressListener = new ProgressListener(){
private long megaBytes = -1;
// only update the percent if more than a MB has been uploaded.
public void update(long pBytesRead, long pContentLength, int pItems) {
long mBytes = pBytesRead / 1000000;
if (megaBytes == mBytes) {
return;
}
megaBytes = mBytes;
// compute percent uploaded.
if(pContentLength > 0) {
float percent = pBytesRead / pContentLength;
// percent needs to be communicated to the client
// progress bar
}
}
};