0

I have recently updated my application to Vaadin 23 from Vaadin 14, and I have discovered that I can no longer add a column to a vaadin grid that uses a Component Renderer to create an SVG containing a circle element. Which I was able to do in Vaadin 14.

See below for an example of a simple project that demonstrates what I was able to do in Vaadin 14 but no longer works in Vaadin 23, and I have tested this code in both.

For clarity machine.getRunningStatusColour().hexCode returns a String to set the colour of the circle.

import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.svg.Svg;
import com.vaadin.flow.component.svg.elements.Circle;
import com.vaadin.flow.data.renderer.ComponentRenderer;
import com.vaadin.flow.router.Route;
import uk.co.dhl.smas.backend.machine.Machine;
import uk.co.dhl.smas.backend.machine.MachineService;

@Route("simple-push")
public class SimpleLayout extends VerticalLayout {

public SimpleLayout(MachineService machineService) {
    setSizeFull();

    Grid<Machine> grid = new Grid<>();
    grid.addColumn(new ComponentRenderer<>(this::svgLayout));
    grid.setItems(machineService.findAll());
    grid.setSizeFull();

    add(grid);
}

private Svg svgLayout(Machine machine) {
    Svg svg = new Svg();
    Circle circle = new Circle("1", 15);
    circle.setFillColor(machine.getRunningStatusColour().hexCode);
    svg.add(circle);
    return svg;
}

}

When running this locally using Vaadin 14 and navigating to simple-push, the page will display a grid with a single column containing 6 rows each with a coloured circle. When using Vaadin 23 only the grid appears with 6 rows but no coloured circle.

Its also worth noting that I am running Java 15 when running Vaadin 14 and Java 17 when running Vaadin 23.

Any help much appreciated, If I have missed anything that you think is relevant please let me know and I will include.

  • That Svg component is not part of the core framework. So you probably use an add-on component, which has not been updated for Vaadin 23 yet. – Tatu Lund Mar 04 '23 at 09:52

0 Answers0