Content is not being show after I press a buttton

Hi guys. I am new to Vaadin.
I press a button on one page and it does nothing even though I ask it to show a certain thing.
Here is the code where the button is:
init { command(item = report) { ClientR() }
Cicking the “report” button calls the ClientR class init.
And this is the init of my ClientR class:
init { val table = PivotTable(createTable(), createOptions(), PivotMode.INTERACTIVE) setContent(table) }
The class obviously has functions and properties that help create table (which is a Vaadin component)

I suppose ClientR is something extending a Vaadin Component, but it seems like you are not adding the instance in the current UI tree.
I mean, you create a new ClientR , but it is not added to a layout or component container.

ClientR extends from AppLayout (so that I can use the function setContent. I also tried the following but in vain.
init { val menu = VerticalLayout() val table = PivotTable(createTable(), createOptions(), PivotMode.INTERACTIVE) menu.add(table) addToDrawer(menu) }

Also, thanks for taking the time to answer.

can you please post the whole classes?


Give me a minute.

ClientR.kt (2.24 KB)

This is in kotlin btw

Do you need the other class also? The only relevant part is that code I sent.

Yes, I need to see where ClientR is used

I am trying to implement PivotTable in my project.


ClientForm.kt (6.08 KB)

This is basically ClientForm on the web

I press the “Report” button, and it does nothing. (It does not remove this content and show the pivottable instead)

What does the command method?
As mentioned above, my suspect is that you are not adding ClientR to the UI

It basically adds a new command to that blue bar. Commands are interactive buttons like quitting, or generating pdf, or creating report, etc.
The old functional code (withouy my pivottable implementation) used a function called “createReport { ClientR }”, ClientR extending from a Report class.
I had to remove the createReport function since my clientR will be extending from AppLayout instead (since it is not possible to inherit from two classes in Kotlin).

Anyway, I verified that command is actually calling my clientR class (by trying to print in the init of clientR class), so the call is happening correctly. What’s not happening correctly is the showing of the pivottable component on the page (on a new blank page or something)

Only creating a new instance will not make the component appear.
the instance should be added to the UI
In your case I would say that the ClientR class is a view that should be annotated with @Route and your button should navigate to that view, e.g UI.getCurrent().navigate(ClientR.class)