@@ -17,7 +17,7 @@ As a real example of using this framework, see [TabShell](https://github.com/tec
1717 * [ Component Structure] ( #component-structure )
1818 * [ Component Lifecycle] ( #component-lifecycle )
1919 * [ Component Hierarchy] ( #component-hierarchy )
20- * [ Composite Component] ( #composite- component )
20+ * [ Component Composer ] ( #component-composer )
2121 * [ When to Create a Component?] ( #when-to-create-component )
2222 * [ When not to Create a Component?] ( #when-not-to-create-component )
2323* [ Requirements] ( #requirements )
@@ -144,8 +144,9 @@ exclusively between the `ComponentViewModel` and the `ComponentHistory`. When th
144144transitions to ` DEINITIALIZED ` , data from the ` ComponentViewModel ` is saved back to the ` ComponentHistory ` . The volume
145145of state information that is restored and persisted is defined by the ` HistoryPolicy ` enum.
146146
147- The ` ComponentComposer ` is responsible for managing child components and their composition, while the ` ComponentMediator `
148- allows ` ComponentViewModel ` to interact with the ` ComponentComposer ` (see [ Composite Component] ( #composite-component ) ).
147+ The ` ComponentComposer ` is responsible for managing child and derived components and their composition, while the
148+ ` ComponentMediator ` allows ` ComponentViewModel ` to interact with the ` ComponentComposer `
149+ (see [ Component Composer] ( #component-composer ) ).
149150
150151### Component Lifecycle <a name =" component-lifecycle " ></a >
151152
@@ -194,15 +195,17 @@ between the presentation (`View`) and logic (`ViewModel`) layers. This design en
194195across the component tree without violating the Unidirectional Hierarchy Rule (UHR), as the relationships are strictly
195196hierarchical and non-cyclic.
196197
197- ### Composite Component <a name =" composite- component" ></a >
198+ ### Component Composer <a name =" component-composer " ></a >
198199
199- Components can be either simple or composite. A simple component has no child components. A composite component has
200- one or more child components. The use of ` Composer ` and ` Mediator ` is required only for components that manage children
201- or dynamically create other components, such as dialogs, panels, or complex containers. Working with a composite
202- component is one of the most challenging parts of using the platform for the following reasons:
200+ The ` ComponentComposer ` is responsible for:
201+ 1 . Creating, positioning, and managing child components (those that will reside directly inside this component).
202+ 2 . Creating and positioning derived components (those that will be provided to another component after creation,
203+ e.g., dialogs, tabs, system notifications, etc.).
203204
204- 1 . MVVM Gap. MVVM does not specify how child components should be created, how their lifecycle should be managed, or
205- how they should be composed.
205+ Working with a composite component is one of the most challenging parts of using the platform for the following reasons:
206+
207+ 1 . MVVM Gap. MVVM does not specify how child and derived components should be created, how their lifecycle should be
208+ managed, or how they should be composed.
2062092 . Architectural Conflict. According to MVVM, the ` ViewModel ` must not know about the ` View ` , yet the ` ViewModel ` may
207210need to initiate the creation of new components (for example, opening a dialog) and their composition — which is
208211impossible without interacting with the ` View ` .
@@ -213,12 +216,11 @@ since names like `SomeComponentViewComposer` and `SomeComponentViewModelComposer
213216must be created: ` ChildView ` extends ` ParentView ` , ` ChildViewModel ` extends ` ParentViewModel ` , ` ChildComposer ` extends
214217` ParentComposer ` etc.
215218
216- In MVVM4FX, the solution for working with composite components is implemented using two classes: ` Composer ` and ` Mediator ` :
219+ In MVVM4FX, the solution is implemented using two classes: ` ComponentComposer ` and ` ComponentMediator ` :
217220
218- ` Mediator ` . This is the interface that the ` ViewModel ` uses to interact with the ` Composer ` . The need for an
219- interface is driven by two factors: first, it allows the ` ViewModel ` to be tested independently of other components;
220- second, the ` Composer ` must know about both the ` View ` and the ` ViewModel ` , while the ` ViewModel ` must not know about
221- the ` View ` .
221+ ` Mediator ` . This is the interface that the ` ViewModel ` uses to interact with the ` Composer ` . This interface is needed
222+ for two reasons: first, it allows the ` ViewModel ` to be tested independently; second, it allows the ` Composer ` to
223+ access both the ` View ` and the ` ViewModel ` , without exposing the ` View ` to the ` ViewModel ` .
222224
223225``` java
224226public interface FooMediator extends ChildMediator {
@@ -237,7 +239,7 @@ public class FooViewModel extends AbstractChildViewModel {
237239}
238240```
239241
240- ` Composer ` . This class contains the methods that manage the entire lifecycle of child components, as well as the
242+ ` Composer ` . This class contains the methods to work with child and derived components, as well as the
241243methods the ` View ` uses to interact with the ` Composer ` . In addition, it defines a non-static inner class that
242244implements the corresponding ` Mediator ` .
243245
@@ -248,6 +250,11 @@ public class FooComposer extends AbstractChildComposer<FooView> {
248250
249251 ...
250252
253+ @Override
254+ public FooMediator getMediator () {
255+ return (FooMediator ) super . Mediator();
256+ }
257+
251258 @Override
252259 protected FooMediator createMediator () {
253260 return new FooComposer .Mediator ();
@@ -273,8 +280,7 @@ public class FooView extends AbstractChildView<FooViewModel> {
273280Composer Creation and Initialization. The ` Composer ` is created during the component’s pre-initialization phase via
274281the protected ` AbstractComponentView#createComposer() ` method. Creating the composer at this stage ensures that both
275282the ` View ` and the ` ViewModel ` are fully constructed, allowing the composer to immediately access and interact with
276- their properties and methods. The composer is also initialized during the pre-initialization phase, while its
277- deinitialization takes place in the component’s post-deinitialization phase.
283+ their properties and methods. The composer is initialized before the ` ViewModel ` and deinitialized after the ` ViewModel ` .
278284
279285Advantages of this approach:
280286
0 commit comments