更新时间:2023-12-04 12:26:34
Yes, special packaging is required. You cannot simply toss the Vaadin Grid column renderer implementation classes into a regular Vaadin app.
Two of the three classes needed for a column renderer implementation involve client-side development, rather than the usual server-side development we do commonly in Vaadin app work.
Fortunately, this is easier than it might sound. To just do a simple column renderer, Vaadin fortunately provides some super-classes that do most of the heavy-lifting. So we need not learn about all the gory details of the GWT and JavaScript magic that goes on under the covers in Vaadin.
The path to success involves:
vaadin-archetype-widget
Start a new project using a multi-module Maven archetype provided by the Vaadin team: vaadin-archetype-widget
seen in this list.
addon
moduleOnce you have created a project from that archetype in your IDE, add your three column renderer classes as shown in this screen shot for an Instant
renderer.
Renderer
class goes in the 'addon' module’s main package.RendererConnector
& RendererState
class files go in the 'addon' module’s nested client
package.Of course, in real work you would delete the example MyComponent…
files created by the archetype.
demo
moduleOnce built you can try your column renderer in the 'demo' module’s Vaadin app by importing the package of the 'addon' module. In this case:
import org.basilbourque.timecolrenderers.InstantRenderer;
My successful implementation of a Instant
column renderer was take entirely from three LocalDateTimeRenderer
related classes provided with Vaadin 8.1.3 source code. You can find the current version of these classes by typing LocalDateTimeRenderer
in the GitHub find file feature.