I have a tabView to which I add tabs dynamically based on the option that user chooses in context menu. The following code represents the sample of how tabs are added:
Code: Select all
Tab newTab = new Tab();
newTab.setId("tab_" + (tabIdSequence));
newTab.setTitle(bundle.getString(menuItemKey));
newTab.setClosable(true);
// Adding ui:include programmatically
FacesContext facesContext = FacesContext.getCurrentInstance();
FaceletContext faceletContext = (FaceletContext) facesContext.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
faceletContext.includeFacelet(newTab, viewMenu.getUrlMap().get(menuItemKey));
tabView.setActiveIndex(activeTabIndex);
RequestContext context = RequestContext.getCurrentInstance();
context.update(":tabView");
I've found different solutions for it, but no one worked for me:
1. First I've tried this one: http://stackoverflow.com/questions/2585 ... lected-tab, but it works fine for tabs that are already declared and not added dynamically. Basically, I've changed context.update(":tabView"); to context.update("@(.ui-tabs-panel:visible .tab-content)"); , but it didn't work as new tab is not rendered on the page yet.
2. Then I tried to do something similar to http://stackoverflow.com/questions/1579 ... -closest-f. My update was looking as following context.update("@(.ui-tabs :not(.ui-helper-hidden))");, but also no success. On my opinion it should work, but tab is simply not displayed after being added in java.
So can you advice me some methods how can I update only active tab when I'm adding them dynamically?
Thanks!