Implementing a CRUD using an editable Grid component
In this section, we'll implement a component containing an editable Grid
. The following is a screenshot of the application showing the Grid
component in edit mode:

For simplicity, in this example, we'll omit the add and the delete CRUD operations for now. Let's start by creating a class to encapsulate the component as follows:
public class EditableGridCrud extends Composite { private Grid<User> grid = new Grid<>(); public EditableGridCrud() { initLayout(); initBehavior(); } private void initLayout() { grid.setSizeFull(); VerticalLayout layout = new VerticalLayout(grid); setCompositionRoot(layout); setSizeFull(); } private void initBehavior() { } }
The class, which extends Composite
, declares a Grid
to show User
instances. There are several constructors available in the Grid
class:
Grid()
: Creates a newGrid
, without columns. Columns have to be manually added.Grid(String caption)
: The same asGrid()
, but sets a...