Package dyntabs

Class DynTabTracker

java.lang.Object
dyntabs.DynTabTracker
All Implemented Interfaces:
Serializable

@Named @ViewScoped public class DynTabTracker extends Object implements Serializable
Tracks the state of all dynamic tabs in the current view (session).

This is a @ViewScoped bean that maintains the complete list of DynTab instances (both active and inactive), the tab-by-ID lookup map, the selected tab ID, and the count of active tabs.

Tab list structure:

  • tabList[0..numActive) contains the active (visible) tabs
  • tabList[numActive..n) contains the inactive (placeholder) tabs

When a tab is closed, it is not removed from the list but moved to the inactive region. When a tab is opened, an inactive placeholder is reused and moved to the active region.

Initial tabs are loaded in init() based on DynTabConfig.getInitialTabNames(), using DynTabRegistry to create the DynTab instances.

Author:
DynTabs
See Also:
  • Constructor Details

    • DynTabTracker

      public DynTabTracker()
  • Method Details

    • setNumActive

      public void setNumActive(int numActive)
    • getNumActive

      public int getNumActive()
    • getTabMap

      public Map<String,DynTab> getTabMap()
      Returns the map containing all tabs indexed by their IDs.

      Used in the XHTML template for the rendered attribute of p:tab:

       
       <p:tab id="r0" rendered="#{dynTabManager.tabMap['r0'].active}" />
       
       
      Returns:
      the map containing all tabs (active and inactive) indexed by their IDs
    • init

      @PostConstruct public void init()
    • createId

      protected String createId(int n)
      Creates a DynTab ID using the pattern "r" + n. These IDs also serve as the p:tab component IDs in the XHTML template.
      Parameters:
      n - the tab index number
      Returns:
      the tab ID (e.g. "r0", "r1")
    • setSelectedTabId

      public void setSelectedTabId(String selectedTabId)
    • getSelectedTabId

      public String getSelectedTabId()
    • getTabList

      public List<DynTab> getTabList()
    • getActiveTabList

      public List<DynTab> getActiveTabList()
      Returns the list of tabs that are currently active on screen. This list is modifiable and can be used to change the order of the tabs on the screen. This list is backed by getTabList(), so make sure not to modify both structurally at the same time.
      Returns:
      the list of tabs that are currently active on screen
      See Also:
    • getNumberOfTabsDefined

      public int getNumberOfTabsDefined()
      Returns the number of tabs defined in the template. Now sourced from DynTabConfig instead of the legacy managed-property.
      Returns:
      the total number of tab slots (active + placeholder)
    • getMaxNumberOfTabs

      public Integer getMaxNumberOfTabs()
      Returns the maximum number of tabs the user can open. Now sourced from DynTabConfig.
      Returns:
      the maximum number of open tabs allowed