Skip to content

Commit

Permalink
fix(demo): fix Vaadin 24 runtime error in demo
Browse files Browse the repository at this point in the history
Close #139
  • Loading branch information
javier-godoy authored and paodb committed Apr 24, 2023
1 parent 817ec46 commit c5a5260
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.flowingcode.vaadin.addons.twincolgrid;

import com.vaadin.flow.component.select.Select;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/** Binary compatibility utils for Vaadin 14-24 */
public class CompatibilityExtension {

private static final Method setItems = lookupSetItems();

private static Method lookupSetItems() {
try {
return Select.class.getMethod("setItems", Object[].class);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
}

public static <T> void setItems(Select<T> select, T[] items) {
try {
setItems.invoke(select, (Object) items);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import lombok.experimental.ExtensionMethod;

@SuppressWarnings("serial")
@PageTitle("Orientation")
@DemoSource
@Route(value = "twincolgrid/orientation", layout = TwincolDemoView.class)
@ExtensionMethod(CompatibilityExtension.class) // hide-source
public class OrientationDemo extends VerticalLayout {

private final Set<Book> selectedBooks = new HashSet<>();
Expand Down

0 comments on commit c5a5260

Please sign in to comment.