I've created a simple base view (called SyncBase) with a grid, with its ViewModel and View Controller. Since my application can have anonymous and authenticated users, I want to reuse that view with or without buttons to change the grid contents.
To do so, I created two new classes, based on SyncBase: SyncReadOnly and SyncReadWrite. SyncReadOnly does not add anything to the base view. SyncReadWrite adds a tbar to the grid.
I've created a fiddle to show the classes and their instantiation.
I have a card layout that display the desired grid: without the toolbar (the SyncReadOnly) or with the toolbar (SyncReadWrite).
The example works perfect if and only if I instanciate the SyncReadOnly first. If I create the SyncReadWrite in first place, when I instanciate the SyncReadOnly afterwards, it also gets the toolbar!
To confirm the good behaviour, click on the "Show Grid ReadOnly" in the first place. Afterwards, you can change the views without any problem. But if you click on the "Show Grid ReadWrite" in the first place, both grid will have the toolbar.
I would like to understand this different behaviour. Does it make sense?
Thanks in advance for reading such a long entry.
P.S. I could use a condition in the view initComponent to create the toolbar if the user is authenticated. But I'm trying to instantiate a different class if the user is authenticated or not.