Registering entities in PortalModuleConfig
Every entity annotated with @PortalEntity must be registered in a class extending PortalModuleConfig. The CDI bean must be @ApplicationScoped.
Configuration structure
@ApplicationScoped
class AppModuleConfig : PortalModuleConfig() {
override fun modules() = listOf(
ModuleDef(
name = "MyModule", // must match @PortalEntity.module
label = "My Module",
icon = "layers",
order = 1,
defaultEntity = MyEntity::class.java,
entities = listOf(
EntityRef(entityClass = MyEntity::class.java, group = "Basic", order = 1),
EntityRef(entityClass = AnotherEntity::class.java, group = "Basic", order = 2),
EntityRef(entityClass = UngroupedEntity::class.java, order = 10)
)
)
)
}ModuleDef fields
| Field | Type | Default | Description |
|---|---|---|---|
name | String | — | Module identifier (must match @PortalEntity.module) |
label | String | — | Displayed module name in the sidebar |
labelKey | String | "" | i18n key for label |
icon | String | "folder" | Lucide icon for the module |
order | Int | 0 | Module sort position |
defaultEntity | Class<*> | — | Entity opened when the module is clicked |
entities | List<EntityRef> | [] | List of entities in the module |
EntityRef fields
| Field | Type | Default | Description |
|---|---|---|---|
entityClass | Class<*> | — | JPA entity class |
group | String | "" | Sidebar group heading (empty = no group) |
order | Int | 0 | Sort position within the group/module |
Multi-module example
@ApplicationScoped
class AppModuleConfig : PortalModuleConfig() {
override fun modules() = listOf(crmModule(), catalogModule(), systemModule())
private fun crmModule() = ModuleDef(
name = "CRM", label = "CRM", icon = "users", order = 1,
defaultEntity = Customer::class.java,
entities = listOf(
EntityRef(Customer::class.java, group = "Customers", order = 1),
EntityRef(Lead::class.java, group = "Customers", order = 2),
EntityRef(Country::class.java, group = "Dictionaries", order = 1)
)
)
private fun catalogModule() = ModuleDef(
name = "Catalog", label = "Catalog", icon = "package", order = 2,
defaultEntity = Product::class.java,
entities = listOf(
EntityRef(Product::class.java, group = "Products", order = 1),
EntityRef(Category::class.java, group = "Dictionaries", order = 1),
EntityRef(Supplier::class.java, order = 10)
)
)
private fun systemModule() = ModuleDef(
name = "System", label = "System", icon = "settings", order = 99,
defaultEntity = AuditLog::class.java,
entities = listOf(
EntityRef(AuditLog::class.java, order = 1),
EntityRef(SystemConfig::class.java, order = 2)
)
)
}Last updated on