When we want to display several components on the same page, we can embed the components into each other. Usually a Seaside application consists of a main component which is usually called the root component. All the child components of the root component and their recursive children form a tree of nested components.
Child components are no different to other components or the root component. Note that the component tree of an application might change during the lifetime of a session. Through user interaction new components can be shown and old ones can be hidden.
Seaside requires that each component knows and declares all its visible child components using the method
WAComponent>>children. This allows Seaside to know in advance what components will be visible when building the HTML and configure and trigger some event on these components before the actual rendering happens.
Note that Seaside does not require children to know their parents and the framework also does not provide this information. When instantiating the components such a link can be easily established, but we do not suggest doing so as it would introduce strong coupling between the child component and its parent. For example, it would no longer be easily possible to use the same component in a different context.
Here are the steps that should be performed to embed components within another.
- The parent component initializes the child components in the method
- The parent component defines a method named
childrenthat returns all its direct child component instances, regardless of how and where they are store.
- The parent component renders its child components in the method
html render: aComponent.