Building web applications that can handle file uploads is nothing new, but how do we do it in AJAX without the default (and ugly) HTML file field, and most of all without the page refreshing. GXT, like most other advanced UI toolkits, provides a richer form widget for handling file uploads on the client; the FileUploadField
is the one-stop widget for doing validated file uploads to the server from where we can use any of the many Java APIs for processing.
It turns out that file uploads are handled well and easy to set up too. All we need to do is use the FileUploadField
widget and (optionally) prevent malicious files with a validator, and GXT will do the rest from the client-side perspective. There are several Java APIs for server-side file upload handling, but the Commons IO and Commons FileUpload APIs from the very generous folks at Apache Foundation will suffice.
// basic form configuration final FormPanel formPanel = new FormPanel();...