O'Reilly logo

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

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

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 ...

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