Documentation
Primary version
Primary version
  • Cubbles documentation
  • First steps
    • Generate a project
    • Create a webpackage
    • Create an elementary component
    • Create a compound component
      • Compound slot initialization
  • Runtime extension - RTE
    • User guide
      • RTE Integration
      • The Cubbles TAG API
        • The Cubbles Dependency API
      • The Cubbles Javascript API
        • Interacting with Cubbles from the outside
        • Adding dynamic connections
        • Interacting with Elementary Cubbles from the inside
      • The RTE Processing
        • RTE initialization and rendering timeline
      • The Cubbles IFrame API
        • The Cubbles IFrame Resizer API
      • The Cubbles mutation based start event API
      • FAQs
        • How to manually resolve dependency conflicts?
        • How to create a component instance dynamically?
        • How to render HTML Markup coming from input slot?
        • How to replace a dependency when declaring a component instance?
        • How to synchronize multiple dataflows between component instances?
        • How to handle the copyValue flag for non serializable instances?
    • Contributor guide
      • CIF processing
  • Developing with the vanilla boilerplate
    • Creating a new project
    • Developing elementaries using the vanilla boilerplate
    • Developing compounds using the vanilla boilerplate
    • Using the vanilla boilerplate scripts
  • Coder devtools - CDT
    • User guide
      • Create Cubbles artifacts
      • Upload a Webpackage
      • Generate a README file
      • Rename an artifact
      • Configure network proxy
      • Validate the manifest.webpackage file
      • Change active webpackage
      • Bulk upload of webpackages
      • Release a webpackage
      • Update the RTE version of a webpackage
      • Prepare a webpackage to be released
      • Update webpackage to the next development version
      • Generate a test environment for a component
      • Testing Cubbles components
      • Validate sources
      • Create a demo webpackage
    • Contributor guide
      • Checklist for releasing a new webpackage.modelVersion
  • Terms and concepts
    • Webpackage
    • Artifacts
    • User roles
    • Base
Powered by GitBook
On this page
  • Purpose
  • Prerequisites
  • Introduction
  • Sample case
  • Initialising slots
  • Initialising compound slots
  • Initialising member slots
  1. First steps
  2. Create a compound component

Compound slot initialization

PreviousCreate a compound componentNextRuntime extension - RTE

Last updated 6 years ago

Purpose

To explain how to initialise the value of the slots of a compound component and its members.

Prerequisites

You know how to .

Introduction

Sometimes, it might be useful to initialise the value of a compound component slot or the slot of a member to assure some behaviour when the component is loaded. You can perform this initialisation in the manifest file associated to your component, using the inits property of a compound component definition. In the following sections, we will explore this process and present some related details.

Sample case

To clarify the initialization process, we will use the currency-viewer compound created in .

Initialising slots

You can initialise the slots of a compound component or the slots of its members in the manifest definition using the inits property, which is an array of objects with the following structure:

Property

Requirement

Description

description

Optional

A short description of this initialisation, e.g. responsibility.

memberIdRef

Required only for members initialization

The memberId of the member that contains the slot. It is only necessary if the slot belongs to a member.

slot

Required

slotId of the slot to be initialised

value

Required

The value to init the slot with, it can be an object, an array, a string, a number or a boolean.

If a slot is connected to more than one slot, the initialization will be performed in the order in which the connections were defined in the connections property of the compound component.

Initialising compound slots

If you want to set the initial value of the slot of a component, you should provide the slotId of the desired slot. Remember that when initialising compounds, the memberIdRef property should not be defined.

Initialising member slots

Let's say that we want to have the following default values for our compound:

slot

memberIdRef

Init value

base

currencyConverter

GBP (Pound sterling)

foreignCurrency

currencyConverter

EUR

date

currencyConverter

2016-06-24

To aim that, we should extend the inits property of the compound definition as follows:

    // ...
    "compoundComponents": [
      {
        "artifactId": "currency-viewer",
        // ...
        "inits": [
          {
            "slot": "base",
            "memberIdRef": "currencyConverter",
            "value": "GBP",
            "description": "Pound sterling would be the default base currency"
          },
          {
            "slot": "foreignCurrency",
            "memberIdRef": "currencyConverter",
            "value": "EUR",
            "description": "Euro would be the default target currency"
          },
          {
            "slot": "base",
            "memberIdRef": "currencyConverter",
            "value": "2018-06-23",
            "description": "Default date for the currency conversion"
          }
        ]
      },
      // ...
    ],
    // ...

Note that if the component of a member has been initialised within its definition, that initialisation will be overwritten by the one you define within the compound that contains it as a member.

Result

If you run the demo page of the currency-viewer component, you will note that the input texts have the values that you defined as presented below:

You can also check the results at the .

create compound components
this tutorial
online demo
Initialised members demo