svenmeier / wicket-dnd

Wicket drag-and-drop
20 stars 14 forks source link

No more page expired. #17

Closed d2a-raudenaerde closed 8 years ago

d2a-raudenaerde commented 8 years ago

Hi Sven,

Here is a pull request. I could not get the built-in Eclipse formatter to format the code exactly like yours, so the diff contains more changes than just the functional one. (I think you even use different formats for files, because I noticed sometimes the open braces are on a newline, sometimes trailing) Maybe you just want to ignore this pull request and just take the relevant portions.

The main changes are that both the DragSoruce and the DropTarget check if the markupId is still valid. If not, the Transfer will be rejected.

Maybe a even better solution would be to follow an onNoLongerValid() path, but for now it prevents PageExpiredExceptions. Our end-users this will benefit, because they no longer have to start-over when constructing filters using dnd, it just silently fails now.

I think ideally drag-n-drop should be prevented (this could be done by either putting a veil on the entire page, or disabling drag-n-drop javascript on the global ajax handlers).

d2a-raudenaerde commented 8 years ago

Ah, this will work as well and is a lot simpler / easier to understand. I think the DragSource also needs this, as the DragSource can be removed by ajax as well?

svenmeier commented 8 years ago

In #onExpired() you can handle both cases: the DragSource is no longer present or the actually dragged component inside the DragSource is already removed.

Should the DropTarget no longer be in the component tree, the request will fail anyway, since Wicket cannot resolve the behavior to receive the request.