Vaadin 8; grid table and checkbox renderer

I am using a java POJO as basis for my datamodel. The pojo is used to create mongo documents as well to populate a grid within the user interface. I would like to visualize the boolean fields as checkbox within the grid. I would also like to be able to edit the checkboxes.

Ideally I would like to refer to the column itself and render its associated cells to CheckBox. Some partial hints found based on vaadin 7 but no luck on vaadin 8. Vaadin remains a mysterious environment.

My pojo;

public class Pojo{

String username;
String fieldname;
Boolean include;
Boolean exclude;

public String getUserName() {
    return username;
}
public void setUserName(String userName) {
    this.username = userName;
}

public String getFieldName() {
    return fieldName;
}
public void setFieldName(String fieldName) {
    this.fieldName = fieldName;
}

public Boolean getInclude() {
    return include;
}
public void setInclude(Boolean include) {
    this.include = include;
}
public Boolean getExclude() {
    return exclude;
}
public void setExclude(Boolean exclude) {
    this.exclude = exclude;
}

the relevant java logic;

public class Data extends VerticalLayout {
private TestFormPage dd;

private String userName;
private String getUserName() {
    return username;
}

private void setUserName(String username) {
    this.userName = username;
}

public Data(){

dd = new TestFormPage();

setUserName("onno");

List<Pojo> dataRecords = mongoOperation.find(new Query(Criteria.where("username").is(getUserName())),
            Pojo.class);

/*

  • I guess a renderer is needed here to convert / render the boolean field into a checkbox element ??
    */

    Grid grid = dd.getDataGrid();
    grid.setItems(dataRecords);
    addComponent(dd);

}

Check BooleanSwitchRenderer in this add-on, there is also Vaadin 8 version.


https://vaadin.com/directory/component/grid-renderers-collection-for-vaadin7
​​​​​​​

Thanks Tatu. Somehow the link does not work on my end. And could you please advice how to use it?

There seems to be something wrong with forum, when you copy paste the link to new tab, it works.

it might be me but maven does not connect either. I am looking at the code examples. Thanks for advice.

After a week of trial and error no real progress made. The examples are not suffient for me to understand the scope / possibilities. I have been able to include checkboxes but clicking outside the checkbox will reset the whole table checkboxes to its default setting. Besides the fact that maven still won’t work and the urls are a deadend street… In the end I am now looking at the github pages and associated code to crasp the idea / intent of the implementation. It feels like reverse engineering.