Restricting dropping by tolerance and acceptance
Droppable behavior is highly configurable. There are a lot of options to restrict dropping. They are useful in matching the draggable and droppable components more precisely.
In this chapter, we will meet options for tolerance and acceptance. We will take several h:panelGroup
components and make them droppable with different tolerance and acceptance values.
How to do it…
Tolerance specifies which mode to use for testing if a draggable component is over a droppable target. There are four different tolerance modes. They can be chosen by the tolerance
attribute of p:droppable
. The following code snippet shows four h:panelGroup
components with settings for tolerance:
<h:panelGrid columns="4"> <h:panelGroup id="dropFit" layout="block" styleClass="dropTarget ui-widget-content"> <p class="ui-widget-header">Drop here (tolerance = fit)</p> <p:droppable onDrop="handleDrop" tolerance="fit"/> </h:panelGroup>...