Add componentColumn for certain objects

I have a grid and now I want to add a componentColumn to it. This column should be empty if a specific property is not set, otherwise a specific Icon should be displayed in this row.

Currently I am getting a NullPointerException → java.lang.NullPointerException: Cannot invoke “com.vaadin.flow.component.Component.getParent()” because “renderedComponent” is null

grid.addComponentColumn(breadCrumb → {
BreadCrumb.FLAG flag = breadCrumb.getFlag();
if(flag == null){
return null;
}else{
if(flag == BreadCrumb.FLAG.WARNING){
return VaadinIcon.WARNING.create();
}else if (flag == BreadCrumb.FLAG.REFRESH){
return VaadinIcon.REFRESH.create();
}
}
return null;
}).setHeader(“Flag”);

thanks in Advantage :slightly_smiling_face:

You can’t return null, you can return an empty element like new Span()

thx a lot :slightly_smiling_face:

I think it is a bug. Made a drat PR to get it fixed: fix: Fix NPE if component renderer returns null by mstahv · Pull Request #4360 · vaadin/flow-components · GitHub

Landed, with next version you can hopefully simplify your code a bit :sunglasses:

I never see this as a bug but having this fixed is much better :slightly_smiling_face: