Package dyntabs

Class DynTabRegistry

java.lang.Object
dyntabs.DynTabRegistry

@ApplicationScoped public class DynTabRegistry extends Object
Central registry for all dynamic tab definitions in the application.

Stores tab definitions as Supplier<DynTab> - each time a tab is opened, the Supplier creates a fresh DynTab instance with all the configured data.

Tabs are registered in two ways:

  1. AUTOMATIC: via @DynTab annotation on the bean class. DynTabDiscoveryExtension scans annotations during CDI bootstrap, and this registry picks them up in its @PostConstruct.
  2. MANUAL: by calling register(String, java.util.function.Supplier) from a DynTabConfig subclass. Useful for tabs that require more complex configuration than what the @DynTab annotation offers.

This is the Jakarta EE replacement for the legacy <managed-bean> definitions in faces-config.xml that were used for tab registration in JSF 2.3.

Author:
DynTabs
See Also:
  • Constructor Details

    • DynTabRegistry

      public DynTabRegistry()
  • Method Details

    • init

      @PostConstruct public void init()
      On registry creation, automatically registers all tabs discovered by DynTabDiscoveryExtension during @DynTab annotation scanning.

      This happens AFTER the CDI bootstrap, when the EE environment is fully started, so it is safe to use CDI.current() for bean lookups.

      Sequence of events:

      1. CDI bootstrap: DynTabDiscoveryExtension scans @DynTab annotations and stores them in a static list
      2. Application starts: DynTabRegistry is created as an @ApplicationScoped bean
      3. @PostConstruct: this method reads the static list and registers Suppliers
    • register

      public void register(String name, Supplier<DynTab> tabSupplier)
      Manually registers a tab under the given name.

      Called from DynTabConfig subclasses for tabs that require more complex configuration than what the @DynTab annotation offers.

      Parameters:
      name - the tab name for registration (e.g. "UsersDynTab")
      tabSupplier - the Supplier that creates a DynTab instance on each opening
    • createTab

      public DynTab createTab(String name)
      Creates a new DynTab instance for the given tab name.

      Invokes the Supplier registered under the given name. Each call creates a new instance (the Supplier is invoked fresh each time).

      Parameters:
      name - the registered tab name
      Returns:
      a new DynTab instance
      Throws:
      IllegalArgumentException - if no tab with the given name is registered
    • hasTab

      public boolean hasTab(String name)
      Checks whether a tab with the given name is registered.
      Parameters:
      name - the tab name
      Returns:
      true if the tab is registered