public class CustomElementMixin extends AbstractElementMixin<Element> implements CustomElementMixinInterface {
}
public interface CustomElementMixinInterface {
}
@ElementMixin(targets = Element.class)
public interface CustomElementMixin extends CustomElementMixinInterface {
}
@Route("example")
public class MainView extends VerticalLayout {
static {
ElementMixinProvider.addCustomMixin(CustomElementMixin.class);
}
// ...
}
public class CustomElementMixin extends AbstractElementMixin<Element> implements CustomElementMixinInterface {
public void setCustomAttribute(String value) {
getElement().setAttribute("custom-attribute", value);
}
public String getCustomAttribute() {
return getElement().getAttribute("custom-attribute");
}
}
public interface CustomElementMixinInterface {
void setCustomAttribute(String value);
String getCustomAttribute();
}
@ElementMixin(targets = Element.class)
public interface CustomElementMixin extends CustomElementMixinInterface {
}
@Route("example")
public class MainView extends VerticalLayout {
static {
ElementMixinProvider.addCustomMixin(CustomElementMixin.class);
}
public MainView() {
Button button = new Button("Click me");
button.setCustomAttribute("example");
String customAttribute = button.getCustomAttribute();
add(button, new Label(customAttribute));
}
}