Create multiple data-sly-resource with dynamic name

dheg120

03-04-2019

Hi,

I'm going through a list and I need to dynamically create multiple data-sly-resources, so I understand that a different name must be assigned to each created component. I have the following code but I can not get it to work correctly, I only create 1 component and this is because it is probably assigning the same name to all the components. This is my code, any suggestions?

<sly data-sly-use.lstModel="com.rimac.core.models.TextListModel"></sly>

    <div data-sly-list.lst="${lstModel.lstTextModel}">

         <div data-sly-resource="${ '${lst.titleName}' @ resourceType='/apps/example/components/content/button'}"></div>

    </div>

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

dheg120

04-04-2019

Thanks, finally I was able to solve it:

<sly data-sly-use.modelo="com.xxxxxx.core.models.formularioUnico.TextListModel"></sly>

            <div class="title" data-sly-list.listado="${modelo.lstTextModel}">

                <div data-sly-resource="${@path=listado.titleName,  resourceType='/apps/xxxxx/components/content/titlecustom'}"></div>

            </div>

Tranks all.

Answers (2)

Answers (2)

Prince_Shivhare

04-04-2019

you can also do like this:

<p><div data-sly-resource="${'item{0}' @ format=multival1List.count, resourceType='wcm/foundation/components/parsys'}" data-sly-unwrap></div></p>

Here we are generating the parsys dynamically. so that each component can have a separate unique id.

refer to this: Creating a Tab layout component for Adobe Experience Manager

~ Prince

Arun_Patidar

MVP

03-04-2019

Hi,

You need to do like below:

<div data-sly-resource="${@path=lst.titleName, @ resourceType='/apps/example/components/content/button'}"></div>

e.g.

1724798_pastedImage_1.png