-
Bug
-
Resolution: Duplicate
-
Normal
-
7.0.5
-
Security Level: Jimmy
-
None
When using a Tabbox with a ListModel and adding a new object to the model, the corresponding tab is always added at the end, regardless of the position of the object in the model. The order of the tabs can be corrected by throwing an ContentsChanged or StructureChanged event, but this will cause the tabbox to reinitialize ALL tabs (like when using children binding). Since we are using fulfill to lazily initialize our (expensive) tabpanels, this wastes quite some time.
I investigated a bit further and found a solution in TabboxEngineImpl.Renderer.render:
private void render(Tabbox tabbox, Object value, int index) throws Throwable { ... tabbox.getTabs().appendChild(tab); ... tabbox.getTabpanels().appendChild(tabpanel); ... }
The Renderer completely ignores the index. I copied the TabboxEngineImpl and changed those two lines to:
private void render(Tabbox tabbox, Object value, int index) throws Throwable { ... tabbox.getTabs().insertBefore(tab, tabbox.getTabs().getChildren().size() == index ? null : tabbox.getTabs().getChildren().get(index)); ... tabbox.getTabPanels().insertBefore(tabpanel, tabbox.getTabPanels().getChildren().size() == index ? null : tabbox.getTabPanels().getChildren().get(index)); ... }
Now the tabs are added at the intended position.
- relates to
-
ZK-2715 ListModelList.set(int, Object) triggers repaint of ALL tabs in Tabbox
- Closed