Vaadin Accordion Tabs

Does anyone have an example show how to add multiple components under an accordion tab. I thought I understood it when I captured the addTab return Tab in a map for later use. However, when I pulled it from the map and found that it was basically an immutable proxy I was really disappointed because I have not been able to find an example with more than one component under an accordion tab. Now that’s useless .


I didn’t really use the Accordion that much yet but looking at the way tabs get added it seems like it’s really a 1 Tab = 1 Component thing as you’re directly assigning the component to the tab when adding it.
You can however always just add Layouts as Tabs. You might even make a nice interface by creating a customcomponent which is a Accordion with layouts already added to it. Then you could create a method like addComponenttoTab which retrieves the right layout for the given id (or something) and then adds the Component to the layout.

How would the Accordion (or TabSheet) know how to display the components unless you wrap them in a Layout (or perhaps another ComponentContainer) first? This is how Vaadin (and almost all UI libraries) works in general; ComponentContainers contain components that may in turn be ComponentContainers themselves.

I must be dense in my older age. I cognitively get the idea but I can’t seem to make it work. Can you show me a snippet of code that adds two items to a single accordion tab. Example - a “Patient” tab would have both a “Search Patients” and “Edit Patient” button within the “Patient” tab. I’m sorry but after 30 years of backend work this GUI work is kicking me hard. Thank you for your help on this.

Sure, no problem:[code]
Accordion a = new Accordion();

Layout l = new VerticalLayout();
l.addComponent(new Button(“Search Patients”));
l.addComponent(new Button(“Edit Patient”));

a.addTab(l, “Patient”);