Making a component draggable
Any component can be enhanced with the draggable behavior. To enable the draggable functionality on any PrimeFaces component, we always need a component called draggable
.
In this recipe, we will see how to make a component draggable and learn some basic features of draggable
. To demonstrate these features, we will make several p:panel
components draggable.
How to do it…
A component can be made draggable by using p:draggable
. The value of the for
attribute specifies a search expression for the draggable target. In our case, it matches the ID of p:panel
.
Tip
Chapter 1, Getting Started with PrimeFaces, provides more details on search expressions.
If the for
attribute is omitted, the parent
component will be selected as a draggable ...
Get PrimeFaces Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.