Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Passing variable value from sightly to sling model

Avatar

Avatar
Validate 1
Level 1
LaMind3
Level 1

Like

1 like

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
LaMind3
Level 1

Like

1 like

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
LaMind3
Level 1

01-10-2020

I want pass list index value to sling model.

<sly data-sly-list.img="${guide.itemsList}">
<span>index:  ${imgList.index}</span>

<sly data-sly-use.multi="${'com.mycom.....MultiField' @ index=${imgList.index}' " />

This gives me null value at model. I tried to with pass with quotes , it gets passed as string.

 

Can any one help me to resolve this?

 

 

 

AEM 6.5.0
View Entire Topic

Avatar

Avatar
Give Back 3
MVP
Manjunath_K
MVP

Likes

138 likes

Total Posts

188 posts

Correct Reply

61 solutions
Top badges earned
Give Back 3
Give Back
Boost 50
Boost 5
Boost 3
View profile

Avatar
Give Back 3
MVP
Manjunath_K
MVP

Likes

138 likes

Total Posts

188 posts

Correct Reply

61 solutions
Top badges earned
Give Back 3
Give Back
Boost 50
Boost 5
Boost 3
View profile
Manjunath_K
MVP

01-10-2020

Hi @LaMind3 

Please find below mentioned corrected syntax & try with this.

 

Sightly:

<sly data-sly-use.multi="${'com.mycom.....MultiField' @ index = imgList.index ,context='number'}" />

 

 

Model Class:

@Model(adaptables = SlingHttpServletRequest.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class MultiField{

 

@Inject
private int index;

 

}