9.1.7 Dynamically Embedding Web Components

You can embed Web components dynamically in your Web function application by using the RDML COMPONENT tag with the &FLD option. In most situations, you will see the RDML COMPONENT tag used in LANSA HTML with the component name explicitly specified. However, if you want to set the name of the component when the function is executing, you can dynamically set the component name.

For example, if you have an HTML page which displays product information, the product displayed in the page is dependent on the product requested by the user. In such a page, the information is dynamic. It depends on the product selected when the function is executing.

In your Web function, you would need a field for the product component. It might be called PRODUCT and would be defined as an alpha field. In the HTML page, you would include the following line for the product component:

<RDML COMPONENT="&FLD_PRODUCT">

This line instructs LANSA to use the contents of the PRODUCT field as the name of the Web component to embed.

In your Web function, you can dynamically set the value of the PRODUCT field according to the user request.

CHANGE  FIELD(#PRODUCT) TO("ABC123")

Using the Web Function Editor, you would create a component named ABC123. This component might include some text and images for the specific product.