# MultiModuleTreeActor

The MultiModuleTreeActor is the core class of this 4App. It contains all the business logic for loading the BaseBeans of different Core Engine modules.

The MultiModuleTreeActor extends the Core Engine actor CEPidTreeActor (opens new window) and overrides the methods _asyncLoadChildren and _hasChildren to implement a custom loading behavior for BaseBeans of different modules.

# Loading Root Elements

This actor loads all root elements by analyzing the value of parameter rootModules, which can either be passed programmatically or via layout parameters.

BaseBeans of modules defined in rootModules are valid BaseBeans at root level. By default, the actor uses the class DefaultMultiModuleTreeRootLoader to load the root elements. For a custom root loading behavior, a class implementing the interface can be used: IMultiModuleTreeRootLoader.

# Loading Children

This actor loads all children of a parent by analyzing parameter moduleStructure, which can either be passed programmatically or via layout parameters.

Whenever children of a parent have to be loaded, the actor searches the module of the parent within the moduleStructure map. Each module can have multiple child modules. The type of the relation between parent and child can be defined separately for each child module:

{
  "parent_module_1": [
    {
      "moduleName": "child_module_1",
      "relationField": "field_with_id_of_parent"
    },
    {
      "moduleName": "child_module_2",
      "childLoader": "SomeCustomChildLoader"
    }
  ],
  "parent_module_2": [
    // ... 
  ],
  // ...
}

Each relation can be described by referencing either to a field in the child module that contains the ID of the parent (e.g. pid), or by defining a custom child loader that extends the abstract class MultiModuleTreeChildLoader.

The MultiModuleTreeActor makes use of the class RelationFieldChildLoader to load BaseBeans of field based relations.

# Sorting the BaseBeans

The BaseBeans below one node of the tree can be sorted by different fields. Since the children of a parent can be from different modules, the allowed fields are:

  • id
  • module_name
  • mod_time
  • type
  • created_time
  • friendlyname
  • created_by
  • mod_by
  • mod_by

By default, the BaseBeans are sorted by field friendlyname. To apply another field, use parameter sortField.

To reverse the sort order, parameter sortOrder can be used. Allowed values are asc (default) and desc.

Request missing documentation