Hi Tatu, I am having some difficulties in rendering the grid when add the

Hi Tatu,

I am having some difficulties in rendering the grid when add the BooleanSwitchRenderer in my grid, here is the code snippet -

List<com.mst.machineLearningUi.model.SimplePojo> models = new ArrayList<>();
models.add(new SimplePojo(1, “One”, true, true));
models.add(new SimplePojo(2, “Two”, true, false));
models.add(new SimplePojo(3, “Three”, false, true));
models.add(new SimplePojo(4, “Four”, false,false));
simpleGrid.setItems(models);
BooleanSwitchRenderer booleanRenderer = new BooleanSwitchRenderer<>(SimplePojo::setTruth,“True”,“False”);
booleanRenderer.addItemEditListener(event → {
System.out.println("Boolean switched: "+event.getNewValue());
});
simpleGrid.addColumn(SimplePojo::getId).setId(“id”).setCaption(“Id”);
simpleGrid.addColumn(SimplePojo::getDescription).setId(“description”).setCaption(“Description”);
simpleGrid.addColumn(SimplePojo::isTruth).setId(“truth-value”).setCaption(“Truth Value”);
simpleGrid.addColumn(SimplePojo::isTruth, booleanRenderer).setId(“truth”).setCaption(“Truth”);

With above code, the grid is not rendering anything, however if I comment out last line in the code (simpleGrid.addColumn(SimplePojo::isTruth, booleanRenderer).setId(“truth”).setCaption(“Truth”);) then its able to render the grid with three columns (Id, Description, Truth Value) correctly.

So can you guide me where do I do wrong in above code, please?

I am using vaadin version - 8.8.0 and grid-renderers-collection-addon - 2.6.1.

Your help is highly appreciated.

Thanks,
Sandeep

Did you remember to recompile the widgetset when you took the add-on into use?

Thanks Tatu for quick response, appreciated.

Yes, I did recompile with following commands, pls let me know if I am missing anything.

mvn vaadin:update-theme
mvn vaadin:update-widgetset
mvn vaadin:compile-theme
mvn vaadin:compile

Thanks,
Sandeep

“update-widgetset” is not enough, it will just update the widgetset xml files. See more information on widgetset compiliation in our documentation here: https://vaadin.com/docs/v8/framework/clientside/clientside-compiling.html

You should include plugin configuration described here https://vaadin.com/docs/v8/framework/clientside/clientside-compiling.html#plugin-configuration to your pom.xml default execution, so that widgetset is compiled always during “mvn install” command.

Hi Tatu,

I tried per your suggestions but no luck, here is my plugin details - 

<build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-maven-plugin</artifactId>
            <version>${vaadin.version}</version>
            <configuration>
				<extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
				<webappDirectory>${basedir}/target/classes/VAADIN/widgetsets</webappDirectory>
				<draftCompile>false</draftCompile>
				<compileReport>true</compileReport>
				<style>OBF</style>
				<strict>true</strict>
			</configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>update-theme</goal>
                        <goal>update-widgetset</goal>
                        <goal>compile-theme</goal>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>		
</build>

I am unable to figure out whats wrong in my project. Surprisingly I dont get any error about the plugin or project as well. Your help is highly appreciated.

Regards,
Sandeep