Create Accordion tab from code

I’m trying to create tabs of Accordion from code with UiComponents, but I am not able to resolve Accordion.Tab.class

I tried so:

@Inject
private UiComponents uiComponents;
...
Accordion.Tab tab1 = uiComponents.create(Accordion.Tab.class);

Hi.
Accordion.Tab is not a component. If you want to add a tab to Accordion programmatically use addTab() method.
For example, you need to add an empty tab, so you have to create a new layout and use it in the method

    @Inject
    private UiComponents uiComponents;
    @Inject
    private Accordion accordion;

    @Subscribe
    private void onInit(InitEvent event) {
        VBoxLayout vBox = uiComponents.create(VBoxLayout.class);
        accordion.addTab("Tab1", vBox);
    }
1 Like