Create multiple data-sly-resource with dynamic name | Community
Skip to main content
dheg120
Level 2
April 3, 2019
Solved

Create multiple data-sly-resource with dynamic name

  • April 3, 2019
  • 3 replies
  • 3569 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by dheg120

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.

3 replies

arunpatidar
Community Advisor
Community Advisor
April 3, 2019

Hi,

You need to do like below:

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

e.g.

Arun Patidar
Prince_Shivhare
Community Advisor
Community Advisor
April 4, 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

dheg120
dheg120AuthorAccepted solution
Level 2
April 4, 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.

Level 2
November 1, 2023

I got the same issue, and this helps! Thank you!