Dynamic Component Creation

Official Content
This documentation is valid for:

Using Web Components or SD Components is one of the options available for building a high degree of component re-usability by centralizing behavior in a single object.

The possibility of instantiating specific Components at runtime enables you to have highly dynamic applications. This means you can change the application layout or behavior by instantiating different Components depending on certain application parameters.

Description

When using Components you can achieve a high degree of parameterization by using the Create and CreateFromURL functions to dynamically change the object to be displayed in a certain section of a layout.

To use it, all you have to do is insert a Component Control in any Object and assign the result of the execution of the Create or CreateFromURL Function to the control object property.

The Create function is used to create an instance of a Component. It has two options: static and dynamic.

Create Syntax

Control.Object = Create( xxx, [parameters])

Where:

Control
   It is the name of the Component control added to the object.

xxx
   It is a Component or an attribute/variable containing the Component (*).

parameters
   Is the list of xxx parameters separated by a semicolon.

With the static option you cannot change the web component reference at runtime, while the dynamic option allows you to change the name of the Web Component at run-time, but the parameters and data types are fixed.

(*) Note that in Smart Devices, it is not the name of the panel; refer to Call Variable to know how to name it.

Examples

// Static creation
Control.Object = View.Create( &parm1, &parm2)

// Dynamic Creation using the Create function ( Variable Object with fixed parameters )
&Object = "View" // or something like "sd:WorkWithDevicesPerson.Person.Detail" in Smart Devices
Control.Object = Create(&Object, &parm1, &parm2)

// Dynamic Creation using the CreateFromURL function
&Object = "View"
&link = link( &Object , &parm1, &parm2 )
Control.Object = CreateFromURL(&link)

Web: Check the GeneXus Work With Pattern which uses this feature to create the TabbedView Web Component.

Availability

This feature is available also in Smart Devices as of GeneXus 15 upgrade 12

See also

CreateFromURL function
Create function



Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.