Html5 Support for Apache MyFaces
Project Documentation


Tag name: <fx:dropTarget>
Converter class: org.apache.myfaces.html5.behavior.DropTargetBehavior
Facelet Tag Handler: org.apache.myfaces.html5.handler.DropTargetBehaviorHandler
behavior id: org.apache.myfaces.html5.DropTargetBehavior
Provides Html5 drop functionality to its parent.

Facelets Attributes

Name Type Required Description
acceptMimeTypes javax.el.ValueExpression false If this property is set, only content dropped into this drop zone with defined mime type will be accepted and sent to server-side drop listener. Can be comma separated set or String[] or Collection<String>.

HTML5 DnD allows us to drop anything into drop zone : files from desktop, images on some other document, etc. So this property is a filter. If value is "*", any content dropped into this zone will be accepted.

All type info and data of dropped stuff will be sent to dropListener. For example, if value of this property is "*" and we drop some image from any Html page(even not generated by JSF), dropListener will be triggered with the following data: <table border="1"> <tr> <td>content-type</td> <td>value</td> </tr> <tr> <td>text/uri-list</td> <td></td> </tr> <tr> <td>Text</td> <td></td> </tr> <tr> <td>text/plain</td> <td></td> </tr> <tr> <td>URL</td> <td></td> </tr> </table>
Mime type is "text/x-myfaces-html5-dnd-source" for drag and drop events that is generated by MyFaces-Html5 components and that mime type is defined at {@link DropTargetBehaviorRenderer#DEFAULT_MYFACES_MIME_TYPE}. Default value of this property is "text/x-myfaces-html5-dnd-source", thus only MyFaces generated components can be dropped into the drop target.
action javax.el.ValueExpression false Action to allow for drop operation. Can be one of below:
  • copy: A copy of the source item may be made at the new location.
  • move: An item may be moved to a new location.
  • link: A link may be established to the source at the new location.
  • copyLink: A copy or link operation is permitted.
  • copyMove: A copy or move operation is permitted.
  • linkMove: A link or move operation is permitted.
  • all: All operations are permitted.
  • none: The item may not be dropped.

If nothing is specified, any action will be accepted. Action is set by the hx:dragSource behavior, when the element is generated by a MyFaces-Html5 component that has hx:dragSource behavior. For other elements, action is set by the browser, and can be adjusted by pressing the modifier keys.
dropListener javax.el.MethodExpression false Drop listener to trigger when a successful drop event is happened into this drop target.
Listener method must have a signature of : public void m(org.apache.myfaces.html5.event.DropEvent evt) throws javax.faces.event.AbortProcessingException
In the listener, application can get the parameter sent and other data sent.
for String false {@inheritDoc}
rerender javax.el.ValueExpression false Space separated ids of components to rerender.
Value of this property will be passed through to jsf.ajax.request, thus semantics is same with jsf.ajax.request and f:ajax. Just like those, @all, @this etc. can be used.
types javax.el.ValueExpression false The type of the drop target. Can be comma separated set or String[] or Collection<String>.
If defined, drags from elements that are generated by MyFaces-Html5 components with hx:dragSource behavior, will be filtered. The drag will be accepted if dropTargetTypes of hx:dragSource is one of the allowed. For the drags that are originated from other elements, this property is ignored. Please see acceptMimeTypes property for accepting/rejecting drags from non-MyFaces-Html5 components.