Search in sources :

Example 1 with DragDropEvent

use of org.primefaces.event.DragDropEvent in project primefaces by primefaces.

the class Droppable method queueEvent.

@Override
public void queueEvent(FacesEvent event) {
    FacesContext context = getFacesContext();
    if (ComponentUtils.isRequestSource(this, context)) {
        Map<String, String> params = context.getExternalContext().getRequestParameterMap();
        String eventName = params.get(Constants.RequestParams.PARTIAL_BEHAVIOR_EVENT_PARAM);
        String clientId = getClientId(context);
        AjaxBehaviorEvent behaviorEvent = (AjaxBehaviorEvent) event;
        if ("drop".equals(eventName)) {
            String dragId = params.get(clientId + "_dragId");
            String dropId = params.get(clientId + "_dropId");
            DragDropEvent dndEvent = null;
            String datasourceId = getDatasource();
            if (datasourceId != null) {
                UIData datasource = findDatasource(context, this, datasourceId);
                String[] idTokens = dragId.split(String.valueOf(UINamingContainer.getSeparatorChar(context)));
                int rowIndex = Integer.parseInt(idTokens[idTokens.length - 2]);
                datasource.setRowIndex(rowIndex);
                Object data = datasource.getRowData();
                datasource.setRowIndex(-1);
                dndEvent = new DragDropEvent(this, behaviorEvent.getBehavior(), dragId, dropId, data);
            } else {
                dndEvent = new DragDropEvent(this, behaviorEvent.getBehavior(), dragId, dropId);
            }
            super.queueEvent(dndEvent);
        }
    } else {
        super.queueEvent(event);
    }
}
Also used : DragDropEvent(org.primefaces.event.DragDropEvent) FacesContext(javax.faces.context.FacesContext) AjaxBehaviorEvent(javax.faces.event.AjaxBehaviorEvent) UIData(javax.faces.component.UIData)

Aggregations

UIData (javax.faces.component.UIData)1 FacesContext (javax.faces.context.FacesContext)1 AjaxBehaviorEvent (javax.faces.event.AjaxBehaviorEvent)1 DragDropEvent (org.primefaces.event.DragDropEvent)1