Skip to Content
DocsModule Registration — PortalModuleConfig

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

FieldTypeDefaultDescription
nameStringModule identifier (must match @PortalEntity.module)
labelStringDisplayed module name in the sidebar
labelKeyString""i18n key for label
iconString"folder"Lucide icon for the module
orderInt0Module sort position
defaultEntityClass<*>Entity opened when the module is clicked
entitiesList<EntityRef>[]List of entities in the module

EntityRef fields

FieldTypeDefaultDescription
entityClassClass<*>JPA entity class
groupString""Sidebar group heading (empty = no group)
orderInt0Sort 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