wicket-dnd
wicket-dnd copied to clipboard
Dragging an element while page is refreshed causes PageExpiredException
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?
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.
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.
I'm just using Eclipe's built-in code format.
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.