Create Tabsheet with new tab for each iteration of for loop

Hello,

I am new not only to Vaadin, but also Java in general, so please excuse my ignorance. I have the shell of a program that I am working on improving that is using the Vaadin framework. There is a layout that is being created that lists several details about each iteration of a for loop that is being gathered from a Json output. Currently, it looks like this:

NodeName1
Info1
Info2
Info3
Info4

NodeName2
Info1
Info2
Info3
Info4

NodeName3

I want to take each NodeName and create a tab for it. I would like the label of the Tab to be the node name and the content to be the “Info” data. I have been using the code example in the Vaadin sampler and I was able to get all of the “Info” data in a single tab, but it’s not creating a new tab for each distinct node name. Does anyone have a code example that would showcase doing something like this? I presume it’s possible, but I am struggling with getting it done.

Thank you.

Something like this should work fine: TabSheet tabs=new TabSheet(); for(Node n:nodes){ VerticalLayout l=new VerticalLayout(); for(Info i:n.getInfos()){ l.addComponent(new Label(i.toString()); } tabs.addTab(n.toString(), l); }
Replace data calls with whatever you are working with.

Thanks for that, Thomas. I found out the issue after discussing with a colleague. He helped me find that I had the tab creation too low in the code and it was essentially overwriting the tab with each iteration instead of creating a new one.