Update only active tab when these added dynamically.

UI Components for JSF
Post Reply
Andriy
Posts: 4
Joined: 13 Apr 2016, 15:38

27 May 2016, 12:02

I'd like to know your advises, what should I change in my implementation in order to make it work properly.

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");
What is going to happen is that this code will update the whole tabView, including the tabs that were added previously. And I want to avoid the update of previous tabs.
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!

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Leslienek and 52 guests