Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dragging an element while page is refreshed causes PageExpiredException #16

Open
d2a-raudenaerde opened this issue Jun 28, 2016 · 4 comments

Comments

@d2a-raudenaerde
Copy link

d2a-raudenaerde commented Jun 28, 2016

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?

@svenmeier
Copy link
Owner

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.

@d2a-raudenaerde
Copy link
Author

d2a-raudenaerde commented Jun 29, 2016

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.

@svenmeier
Copy link
Owner

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

@svenmeier
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants