Class LitRendererMigrationExtension

java.lang.Object
com.flowingcode.vaadin.jsonmigration.LitRendererMigrationExtension

public class LitRendererMigrationExtension extends Object
Provides migration support for LitRenderer event handler registration across Vaadin versions.

In Vaadin 24, LitRenderer.withFunction receives a JsonArray from the elemental.json API directly. In Vaadin 25+, the argument type changed to a Jackson ArrayNode, so this class wraps the handler to perform the necessary conversion transparently.

The LitRenderer type referenced here is resolved at runtime via a method handle, allowing this library to compile against Vaadin 14 while supporting Vaadin 24+.

Note: This class is only useful when running on Vaadin 24 or later. On earlier versions, LitRenderer is not available and any attempt to use this class will fail at runtime.

  • Constructor Details

    • LitRendererMigrationExtension

      public LitRendererMigrationExtension()
  • Method Details

    • withFunction

      public static <SOURCE> com.flowingcode.vaadin.jsonmigration.LitRendererMigrationExtension.LitRenderer<SOURCE> withFunction(com.flowingcode.vaadin.jsonmigration.LitRendererMigrationExtension.LitRenderer<SOURCE> renderer, String name, SerializableBiConsumer<SOURCE,elemental.json.JsonArray> handler)
      Registers an event handler function on the given LitRenderer.

      On Vaadin 25+, the raw argument passed by the client is a Jackson ArrayNode rather than a JsonArray, so the handler is wrapped to convert it before forwarding.

      Type Parameters:
      SOURCE - the bean type of the renderer
      Parameters:
      renderer - the LitRenderer on which to register the function
      name - the client-side function name
      handler - the handler to invoke when the client calls the function; receives the item and a JsonArray of arguments
      Returns:
      the same renderer instance, for chaining