Vaadin 23 TabSheet how to get selected Tab?

Hey there,
yes I know there is tabSheet.getSelectedTab();
But I struggle with it a bit…

I have 2 complete Views which one could also navigate to as standalone view. These views go into a Tab as it’s component.
TabsheetView extends Vertical Layout
Tab tab1 = tabSheet.add(“name1”, view1);
Tab tab2 = tabSheet.add(“name2”, view2)
add(tabSheet);

in view2 I want to fill a grid with setItems only when that tab / view is shown.

Any hint? My Idea was to get the selected tab and setItems if it is view2, but right now I’m at the point scratching my head… :thinking:

https://vaadin.com/docs/latest/components/tabs/#lazy-initialization-of-tab-contents

Hey knoobie :slightly_smiling_face:

Yes I have seen that, too, and I’m guessing it is the “correct” way to do it, only I didn’t understood the mechanism about Supplier at once so I hoped there was another way :slightly_smiling_face:

But ok, will try to get that up :slightly_smiling_face: Thanks

well, it might be overkill, depending on your needs.

A simpler approach that might be sufficient is to simply add an attachlistener to view2 and populate the Grid when it’s trigggered

attachlistener is the magic word :slightly_smiling_face: where were my thoughts, simply thought too complicated…

yeah that might be sufficient
the second view just holds a tiny grid, nothing special there, it’s just giving an overview

Thanks you two!