DragDropEvent NullPointerException

UI Components for JSF
Post Reply
slang2310
Posts: 13
Joined: 13 May 2015, 16:13

21 Aug 2015, 11:08

Current XHTML:

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?
Primefaces 6.0
Mojarra 2.2.10
Wildfly 10.1

slang2310
Posts: 13
Joined: 13 May 2015, 16:13

24 Aug 2015, 18:24

Still got no idea, why the data Object is null, but my work-around is now the "dragId" of the DragDropEvent, which can be used to figure out, which object has been dragged on the drop zone.
Primefaces 6.0
Mojarra 2.2.10
Wildfly 10.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 28 guests