@@ -383,6 +383,28 @@ private List<Integer> convertJsonArrayToIntegerList(JsonArray jsonIds) {
383383 return idList ;
384384 }
385385
386+ /**
387+ * Converts a comma-separated string of numeric IDs to a JsonArray.
388+ * <p>
389+ * IDs are received from the client as a string because {@code String} is the only argument type
390+ * that every supported Vaadin version is able to decode for a {@link ClientCallable} method: up
391+ * to Vaadin 24 the RPC decoder only accepts {@code String}, {@code Boolean}, {@code Integer},
392+ * {@code Double} and {@code elemental.json.JsonValue}, while Vaadin 25 decodes with Jackson and
393+ * no longer knows about {@code elemental.json}.
394+ *
395+ * @param ids comma-separated numeric IDs, possibly empty or {@code null}
396+ * @return the IDs as a JsonArray of numbers
397+ */
398+ private JsonArray convertIdsToJsonArray (String ids ) {
399+ JsonArray jsonIds = Json .createArray ();
400+ if (ids != null && !ids .isEmpty ()) {
401+ for (String id : ids .split ("," )) {
402+ jsonIds .set (jsonIds .length (), Double .parseDouble (id .trim ()));
403+ }
404+ }
405+ return jsonIds ;
406+ }
407+
386408 /**
387409 * Appends a list of items to a parent node's children list.
388410 *
@@ -436,14 +458,27 @@ public void addSiblings(Integer nodeId, List<OrgChartItem> siblings) {
436458 }
437459
438460
461+ /**
462+ * Bridge for {@link #onSiblingsAdded(String, JsonArray)}, invoked from the client side. The IDs
463+ * are received as a comma-separated string, since {@code JsonArray} arguments cannot be decoded
464+ * by all supported Vaadin versions.
465+ *
466+ * @param nodeId the ID of the node that received new siblings
467+ * @param siblingIds comma-separated IDs for the newly added siblings
468+ * @see #convertIdsToJsonArray(String)
469+ */
470+ @ ClientCallable
471+ private void onSiblingsAdded (String nodeId , String siblingIds ) {
472+ onSiblingsAdded (nodeId , convertIdsToJsonArray (siblingIds ));
473+ }
474+
439475 /**
440476 * Handles sibling addition events from the client side. Converts the received JsonArray of
441477 * sibling IDs to a List and fires a {@link SiblingsAddedEvent}.
442478 *
443479 * @param nodeId the ID of the node that received new siblings
444480 * @param siblingIds array of IDs for the newly added siblings
445481 */
446- @ ClientCallable
447482 private void onSiblingsAdded (String nodeId , JsonArray siblingIds ) {
448483 // Find the node where siblings were added
449484 OrgChartItem targetItem = getById (Integer .valueOf (nodeId ), orgChartItem );
@@ -518,7 +553,20 @@ public void addChildren(Integer nodeId, List<OrgChartItem> children) {
518553 }
519554 }
520555
556+ /**
557+ * Bridge for {@link #onChildrenAdded(String, JsonArray)}, invoked from the client side. The IDs
558+ * are received as a comma-separated string, since {@code JsonArray} arguments cannot be decoded
559+ * by all supported Vaadin versions.
560+ *
561+ * @param nodeId the ID of the parent node that received new children
562+ * @param childIds comma-separated IDs for the newly added children
563+ * @see #convertIdsToJsonArray(String)
564+ */
521565 @ ClientCallable
566+ private void onChildrenAdded (String nodeId , String childIds ) {
567+ onChildrenAdded (nodeId , convertIdsToJsonArray (childIds ));
568+ }
569+
522570 private void onChildrenAdded (String nodeId , JsonArray childIds ) {
523571 // Find the parent node where children were added
524572 OrgChartItem parentItem = getById (Integer .valueOf (nodeId ), orgChartItem );
0 commit comments