vaadin / vaadin/framework

Delete button on grid causes NullPointerException

Open
#11,750 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

duplicate Stale workaround
Dominant language
Java
Stars
1.8k
Forks
717
Avg merge
2d 6h
Merged PRs (30d)
3

Description

I have a grid configured with button renderer. Button deletes its own element row from the grid. When user attempts to delete multiple rows by clicking on delete button fast, grid produces NullPointerException: "editor can't edit null".

This is because vaadin on client side decides second click is actually double click on just removed row and attempts to open editor.

Similar issue was reported here: https://vaadin.com/forum/thread/16616603/vaadin-8-buttonrenderer-doubleclick

Workaround - create custom grid:

@SuppressWarnings({ "javadoc", "serial" })
public class CustomGrid<T> extends Grid<T> {

	@Override
	protected Editor<T> createEditor() {
		return new FixedEditorImpl<>(getPropertySet());
	}

}

@SuppressWarnings("serial")
class FixedEditorImpl<T> extends EditorImpl<T> {

	public FixedEditorImpl(PropertySet<T> propertySet) {
		super(propertySet);
	}

	@Override
	protected void doEdit(T bean) {
		if (bean == null) {
			cancel();
			return;
		}

		super.doEdit(bean);
	}

}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Vaadin Grid's button renderer and editor path, especially Grid#createEditor and EditorImpl#doEdit, using the reproduction described in the issue. Done means rapidly deleting multiple rows no longer treats the second click as a double-click on the removed row or raises "editor can't edit null".

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.