O'Reilly logo

PrimeFaces Cookbook by Mert Çalışkan, Oleg Varaksin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Uploading a file with drag-and-drop

In supported browsers, a file can also be dragged-and-dropped for uploading with fileUpload, and the component itself will be the drop zone.

How to do it...

The dragDropSupport attribute defines whether or not to enable drag-and-drop from the filesystem. By default, the value of this attribute is true. In order to provide drag-and-drop support, the fileUpload component should be in advanced mode, which is the default mode. The definition of the fileUpload component for uploading files with drag-and-drop would be as follows:

<p:fileUpload id="upload" value="#{fileController.file}"
  dragDropSupport="true"
  update="growl"
  fileUploadListener="#{fileController.handleFileUpload}" />

How it works...

The fileUploadListener ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required