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);
}
}
Aggregations