Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Need Help with Grid cells
(New in Vaadin) I have a Grid with an IndexedContainer. This Grid is planned to be filled with the user information and then stored. It has a button to add as many rows as the user need. The problem is that some columns have to be ComboBoxes, cells accepting only Hour format and a Button. Something like this:
Column Hour (Hour format), Column JobType (ComboBox), Column EndHour(Hour Format), Column Description(String), Column ButtonRemove(Button).
How can I add them?
Components in grid cells aren't supported (yet) by the core framework, however there is an add-on for that (which I'm currently using): https://vaadin.com/directory#!addon/componentrenderer
For the hour format, you'll need to use a converter (StringToIntegerConverter) and validator (IntegerRangeValidator) for each column. How you do that will depend on whether you are using Vaadin 7 or 8.
Many thanks Ian Scriven,
I'm checking and installing the Vaadin add-on you recommend.
Can I ask you an example about the converter and the validator that you mentioned?
Sorry for the disturbances.
Based on your other post in this forum I'm going to guess you're planning on using Vaadin 8.
(I'm writing this code on the directly here, so there might be some syntax errors) (also I'm new to Vaadin 8 so there might be better/cleaner ways of doing this)
// the bean in the grid
public class GridRow {
private int hours; // 0 - 23
// other data
public int getHours() { return hours; }
public void setHours(int hours) { this.hours = hours; }
}
// in the view/UI
...
Grid<GridRow> grid = new Grid<>(GridRow.class);
Binder<GridRow> binder = grid.getEditor().getBinder();
TextField hoursField = new TextField();
// in Vaadin 7 you'd add the Converter/Validator directly to the TextField
Binder.Binding<GridRow, Integer> hoursBinding = binder.forField(hoursField)
.withConverter(new StringToIntegerConverter)
.withValidator(new IntegerRangeValidator("Value must be between 0 and 23", 0, 23))
.bind(Person::getHours, Person::setHours);
// in Vaadin 7 you'd do grid.addColumn("hours").setEditorField(hoursField)
grid.addColumn("hours").setEditorBinding(hoursBinding);
// enable grid editing, define listeners for editing events
...
Hope that helps