Skip to content

Support LitRenderer.withFunction across Vaadin 24/25 (elemental.json JsonArray vs Jackson ArrayNode) #33

@javier-godoy

Description

@javier-godoy

Feature proposal

LitRenderer.withFunction(name, handler) registers a client-callable function whose arguments are delivered to the server-side handler as a JSON array. The handler signature differs by Vaadin version:

  • Vaadin ≤24: the handler receives an elemental.json.JsonArray.
  • Vaadin 25+: Vaadin switched its JSON layer to Jackson, so the same handler now receives a com.fasterxml.jackson.databind.node.ArrayNode.

Code written against the elemental.json signature (SerializableBiConsumer<SOURCE, JsonArray>) therefore breaks on Vaadin 25. JsonMigrationHelper should offer a compatibility helper so a single withFunction handler written against elemental.json.JsonArray works unchanged across Vaadin 24 and 25+, consistent with the rest of the add-on's JSON compatibility surface (setPropertyJson, executeJs, getEventData, @ClientCallable/@LegacyClientCallable, …).

Describe solution expectations

A static helper, e.g.:

LitRendererMigrationExtension.withFunction(renderer, name, (source, JsonArray args) -> { ... });
  • On Vaadin <25, delegate directly to renderer.withFunction(name, handler).
  • On Vaadin 25+, wrap the handler so the incoming ArrayNode is converted to JsonArray via JsonMigration.convertToJsonValue(...) before the user handler is invoked.
  • Since the library compiles against Vaadin 14 (where LitRenderer does not exist), the LitRenderer reference would be resolved at build time using the same ASM post-processing mechanism already used elsewhere in the project.
  • Usable with Lombok @ExtensionMethod(JsonMigration.class) for fluent syntax.

Additional information

This is the LitRenderer counterpart to the JSON elemental.json ↔ Jackson conversion the add-on already provides for other Vaadin APIs.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Status
In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions