Grid with container - How to add a new row

I’m trying to create a grid that use the inline editor. With a few effort the grid which use a BeanItemContainer is working very nice for update the existing rows.

But now I don’t know how is the best way to add new rows to the grid.

I created a button to add a new row that add a new bean to the container, after that it appears on the grid (with blank columns). After that I need to double click to open the inline editor and when I press save the grid shows back the original added bean, the columns get blank again.

What I want to achieve is when I press Add, the added row alread opens the inline editor, and the saved bean be show on the edited row.

Thank you in advance.

After adding the item, you can call editItem() to edit it. If the user presses Cancel while editing the new item, the cancelEditor() is called. You can probably intercept that by extending Grid and overriding the method, and remove the empty item if necessary. I hope it works somewhat like that; there’s still some limitations with the editor.


Now everything works fine as intented. I use Ebean for data access and I don’t know exactly why(I think Ebean enhencement) , but If I save the bean when I add it to the container and later save again when I click ‘Save’ in the inline-editor it works like a charm.

My unique complain is when you double click to open the inline editor, it must focus on the first editable column. The way it is show now is not evident to the user that it can modify the column, because nothing change in the row, just outside, but nothing like when you change a TextField for example, where there is a border showing the focus and the cursor is blinking inside.


Can you please provide me some sample example