PrimeFaces DragDropropEvent NullPointerException
尽管如此,我的问题与另一个问题非常相似,但并不完全相同 我当前的XHTML如下所示:PrimeFaces DragDropropEvent NullPointerException,primefaces,nullpointerexception,drag-and-drop,Primefaces,Nullpointerexception,Drag And Drop,尽管如此,我的问题与另一个问题非常相似,但并不完全相同 我当前的XHTML如下所示: <p:dataGrid id="availableAttachments" value="#{orgUnitCRBean.orgUnit.attachments}" var="attachment" varStatus="status"> <p:draggable revert="true" for="attachmentButton#{status.index}" disabled=
<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>
/*
* 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();
}
DragDropEvent不包含任何数据,因此我在这里得到一个NullPointerException。从我的角度来看,我真的很接近从PrimeFaces的展示。在网上发现了几个类似的问题,但没有合适的答案。也许有人知道该怎么做,在这里?仍然不知道为什么数据对象是空的,但我的变通方法现在是DragDropEvent的“dragId”,可以用来确定哪个对象被拖到了拖放区。仍然不知道为什么数据对象是空的,但我的变通方法现在是“dragId”DragDropEvent的,可用于确定在放置区域上拖动了哪个对象