Expand my Community achievements bar.

SOLVED

Create multiple data-sly-resource with dynamic name

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Level 2

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.

View solution in original post

4 Replies

Avatar

Community Advisor

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



Arun Patidar

Avatar

Community Advisor

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

Avatar

Correct answer by
Level 2

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.