wicket-dnd icon indicating copy to clipboard operation
wicket-dnd copied to clipboard

Dragging an element while page is refreshed causes PageExpiredException

Open d2a-raudenaerde opened this issue 8 years ago • 4 comments

I have quite a large application that centers around search. On the left, there is a dropzone (for facets) where items from a list can be dropped. When an item is dropped, a query is modified, an Ajax-refresh is done and the list is refreshed. This works great as long as the user has enough patienct to wait for the center-list to be re-rendered by the browser.

However, it is possible for the user to quickly drag-and-drop TWO items in quick succession from the center to the left. The first causes a refresh of the list, so the markup-id's are no longer valid. However, because the browser so not yet received the new center, there are still items that can be dragged. These items will have invalid markup-ids. When the user drops the second item on the dropzone, a PageExpiredException is thrown by the MarkupIdVisitor.getComponent() in de getDrag() of the DragSource

I think it would be nice if the transfer can be rejected if the original item no longer exists. Currently it is not possible to prevent this behaviour.

What do you think? Maybe there are better methods of dealing with this problem?

d2a-raudenaerde avatar Jun 28 '16 11:06 d2a-raudenaerde

Well, this is a common issues with long-running Ajax requests. Most of the time applications prevent further Ajax requests by showing a veil.

You could try using stable markup, e.g. using some database id.

Please report back whether you can make it work.

svenmeier avatar Jun 28 '16 19:06 svenmeier

Hi Sven,

I got a version that checks if the dragsource / droptarget still exists. If not, it rejects the dnd. This surely can be improved upon, but for now it prevents all the PageExpiredExceptions.

However, I used my custom formatter to the format is a bit off and a pull-request will be ugly. Do you use a formatter (if so, which?) Then I'll create a pull-request.

d2a-raudenaerde avatar Jun 29 '16 13:06 d2a-raudenaerde

I'm just using Eclipe's built-in code format.

svenmeier avatar Jun 29 '16 13:06 svenmeier

Many thanks for your pull request. I've opted for a slightly simpler solution: you can override DropTarget#onExpired() and just handle the PageExpiredException there.

svenmeier avatar Jun 29 '16 20:06 svenmeier