Send your remarks, comments or wishes to doc team
Subject:
Message:
Your name:
Your email:

JBoss.org Community Documentation

- Prev
- Next

## 6.46. < rich:dragSupport >

### 6.46.1. Description

This component defines a subtree of the component tree as draggable for drag-and-drop operations. Within such a "drag zone," you can click the mouse button on an item and drag it to any component that supports drop operations (a "drop zone"). It encodes all the necessary JavaScript for supporting drag-and-drop operations.

Figure 6.94. <rich:dragSupport> component

### 6.46.2. Key Features

- Encodes all necessary JavaScript to perform drag actions

- Can be used within any component type that provides the required properties for drag operations

- Supports drag-and-drop between different forms

Table 6.189. rich : dragSupport attributes

Attribute Name | Description
--- | ---
action | MethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListener | MethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingle | boolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
binding | The attribute takes a value-binding expression for a component property of a backing bean
bypassUpdates | If "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
data | Serialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disableDefault | Disable default action for target event (append "return false;" to JavaScript)
dragIndicator | Id of a component that is used as drag pointer during the drag operation
dragListener | MethodBinding representing an action listener method that will be notified after drag operation
dragType | A drag zone type that is used for zone definition, which elements can be accepted by a drop zone
dragValue | Data to be sent to a drop zone after a drop event
eventsQueue | Name of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focus | id of element to set focus after request completed on client side
grabbingCursors | list of comma separated cursors that indicates then the you has grabbed something
grabCursors | List of comma separated cursors that indicates then you can grab and drag an object
id | Every component may have a unique id that is automatically created if omitted
ignoreDupResponses | Attribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediate | True means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
limitToList | If "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
onbeforedomupdate | JavaScript code for call before DOM has been updated on client side
oncomplete | JavaScript code for call after request completed on client side
ondragend | A JavaScript event handler called after a drag operation
ondragstart | A JavaScript event handler called before drag operation
ondropout | A JavaScript event handler called after a out operation
ondropover | A JavaScript event handler called after a drop operation
process | Id['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rendered | If "false", this component is not rendered
requestDelay | Attribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRender | Id['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingId | If there are any component requests with identical IDs then these requests will be grouped.
status | ID (in format of call UIComponent.findComponent()) of Request status component
timeout | Response waiting time on a particular request. If a response is not received during this time, the request is aborted
value | The current value for this component

Table 6.190. Component identification parameters

Name | Value
--- | ---
component-type | org.richfaces.DragSupport
component-class | org.richfaces.component.html.HtmlDragSupport
component-family | org.richfaces.DragSupport
renderer-type | org.richfaces.DragSupportRenderer
tag-class | org.richfaces.taglib.DragSupportTag

### 6.46.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:

    ...

        <h:panelGrid id="drag1">

            <rich:dragSupport dragType="item"/>

                <!--Some content to be dragged-->

        </h:panelGrid>

    ...

### 6.46.4. Creating the Component Dynamically Using Java

Example:

    import org.richfaces.component.html.HtmlDragSupport;

    ...

    HtmlDragSupport myDragZone = new HtmlDragSupport();

    ...

### 6.46.5. Details of Usage

The dragSupport tag inside a component completely specifies the events and JavaScript required to use the component and it's children for dragging as part of a drag-and-drop operation. In order to work, though, dragSupport must be placed inside a wrapper component that outputs child components and that has the right events defined on it. Thus, this example won't work, because the <h:column> tag doesn't provide the necessary properties for redefining events on the client:

Example:

    ...

        <h:column>

            <rich:dragSupport dragIndicator=":form:iii" dragType="text">

                <a4j:actionParam value="#{caps.name}" name="name"/>

            </rich:dragSupport>

            <h:outputText value="#{caps.name}"/>

        </h:column>

    ...

However, using a4j:outputPanel as a wrapper inside <h:column> , the following code could be used successfully:

Example:

    ...

        <h:column>

            <a4j:outputPanel>

                <rich:dragSupport dragIndicator=":form:iii" dragType="text">

                    <a4j:actionParam value="#{caps.name}" name="name"/>

                </rich:dragSupport>

                <h:outputText value="#{caps.name}"/>

            </a4j:outputPanel>

        </h:column>

    ...

This code makes all rows of this column draggable.

One of the main attributes for dragSupport is "dragType" , which associates a name with the drag zone. Only drop zones with this name as an acceptable type can be used in drag-and-drop operations. Here is an example:

Example:

    ...

        <h:panelGrid id="drag1">

            <rich:dragSupport dragType="singleItems" .../>

            <!--Some content to be dragged-->

        </h:panelGrid>

    ...

        <h:panelGrid id="drag2">

            <rich:dragSupport dragType="groups" .../>

            <!--Some content to be dragged-->

        </h:panelGrid>

    ...

        <h:panelGrid id="drop1">

            <rich:dropSupport acceptedTypes="singleItems" .../>

            <!--Drop zone content-->

        </h:panelGrid>

    ...

In this example, the `drop1` panel grid is a drop zone that invokes drag-and-drop for drops of items from the first `drag1` panel grid, but not the second `drag2` panel grid. In the section about dropSupport , you will find an example that shows more detailed information about moving data between tables with drag and drop.

The dragSupport component also has a "value" attribute for passing data into the processing after a drop event.

One more important attribute for <rich:dragSupport> is the "dragIndicator" attribute that point to the component id of the <rich:dragIndicator> component to be used for dragged items from this drag zone. If it isn't defined, a default indicator for drag operations is used.

Finally, the component has the following extra attributes for event processing on the client:

- "ondragstart"

- "ondragend"

You can use your own custom JavaScript functions to handle these events.

## Note:

If you define width for a outputPanel, in Internet Explorer 6 you can perform a drag and drop operation, placing the mouse cursor on the text in the outputPanel only.

Information about the "process" attribute usage you can find here .

### 6.46.6. Look-and-Feel Customization

<rich:dragSupport> has no skin parameters and custom style classes , as the component isn't visual.

### 6.46.7. Relevant Resources Links

Here you can see the example of <rich:dragSupport> usage and sources for the given example.

- Prev6.45. < rich:dragIndicator >
- Top of page
- Front page
- Next6.47. < rich:dropSupport >