Add-on encapsulating Add row to Grid - Edit - Delete by Cancel sequence in extended Button
Vaadin 7 Grid does not yet have editor event. This is a small short coming if you want to create button to add a row to your grid with the following logic
- Click button to add a row
- Activate editor on the new row
- Delete row if user selected to click cancel instead of save
Hence I wrote this experimental add-on, which encapsulates needed logic in form of extended Vaadin Button.
- Works currently only with BeanItemContainer
- Uses threads, hence Push needs to be enabled
- Beans used with AddRowButton must have default constructor without parameters in order to intanstiate
- Doesn't work with Vaadin 7.6.1 - 7.6.2 due layout bug in Editor
- Doesn't work with Vaadin 7.5.4 and older due bug Grid row book keeping
Status of this utility is experimental. I hope this is also useful demo case how to work with Vaadin using threads.
Setup the Grid first.
- Create new AddRowButton using its constructor.
AddRowButton button = new AddRowButton(String caption, Grid grid,Class<?> MyBean.class);
caption: the caption of the button MyBean: the beantype of your bean grid: the grid you use this utility with