Package dyntabs
Class DynTabRegistry
java.lang.Object
dyntabs.DynTabRegistry
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:
- AUTOMATIC: via
@DynTabannotation on the bean class.DynTabDiscoveryExtensionscans annotations during CDI bootstrap, and this registry picks them up in its@PostConstruct. - MANUAL: by calling
register(String, java.util.function.Supplier)from aDynTabConfigsubclass. Useful for tabs that require more complex configuration than what the@DynTabannotation 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a new DynTab instance for the given tab name.booleanChecks whether a tab with the given name is registered.voidinit()On registry creation, automatically registers all tabs discovered byDynTabDiscoveryExtensionduring@DynTabannotation scanning.voidManually registers a tab under the given name.
-
Constructor Details
-
DynTabRegistry
public DynTabRegistry()
-
-
Method Details
-
init
@PostConstruct public void init()On registry creation, automatically registers all tabs discovered byDynTabDiscoveryExtensionduring@DynTabannotation 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:
- CDI bootstrap: DynTabDiscoveryExtension scans
@DynTabannotations and stores them in a static list - Application starts: DynTabRegistry is created as an
@ApplicationScopedbean @PostConstruct: this method reads the static list and registers Suppliers
- CDI bootstrap: DynTabDiscoveryExtension scans
-
register
Manually registers a tab under the given name.Called from
DynTabConfigsubclasses for tabs that require more complex configuration than what the@DynTabannotation offers.- Parameters:
name- the tab name for registration (e.g. "UsersDynTab")tabSupplier- the Supplier that creates a DynTab instance on each opening
-
createTab
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
Checks whether a tab with the given name is registered.- Parameters:
name- the tab name- Returns:
- true if the tab is registered
-