Code: Select all
<p:dataGrid id="availableAttachments" value="#{orgUnitCRBean.orgUnit.attachments}" var="attachment" varStatus="status">
<p:draggable revert="true" for="attachmentButton#{status.index}" disabled="false" readonly="false" rendered="true"/>
<p:panel toggleable="false" disabled="false" id="attachmentButton#{status.index}" readonly="false" rendered="true" title="#{attachment.fileName}" value="#{attachment.fileName}">
<p:commandButton ajax="false" disabled="false" readonly="false" rendered="true" value="#{attachment.fileName}">
<p:fileDownload value="#{orgUnitCRBean.handleFileDownload(attachment)}"/>
</p:commandButton>
</p:panel>
</p:dataGrid>
<p:droppable activeStyleClass="ui-state-highlight" dataSource="availableAttachments" tolerance="touch" for="attachmentPanel" disabled="false" readonly="false" rendered="true">
<p:ajax listener="#{orgUnitCRBean.handleFileDelete}" update="@form" disabled="false" readonly="false" rendered="true"/>
</p:droppable>
BeanCode:
Code: Select all
/*
* Delete an attachment.
*/
public void handleFileDelete(DragDropEvent ddEvent) {
Attachment attachment = ((Attachment) ddEvent.getData());
System.out.println("Attachment: " + attachment);
UUID id = attachment.getId();
String idToBeDeleted = attachment.getId().toString();
}
The DragDropEvent doesn't contain any data, so I get a NullPointerException here. From my point of view I'm really close to the showcase now. Found a couple of similar questions on the net, but no answer. Maybe someone knows what to do, over here?