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

How to pass multiple parameters to sling model from sightly

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

09-12-2020

I have written sling model exporter . I need to call this by passing 2 parameters fileReference & imgParam

<sly data-sly-use.slingmodel="com.myproj.core.models.TestSlingModel"  @ fileReference ='/some/path/to/file' , @ imgParam='image'/>

 

In sling model (@Model(adaptables = {Resource.class, SlingHttpServletRequest.class})

I have written:

@getter
@ValueMapValue
private String fileReference;

 

@getter
@ValueMapValue
private String imgParam;

 

I am not able to pass parameters properly. Can anyone tell me if this is right way of passing multiple parameters?

 

 

AEM 6.5.5.0 Sling Model
View Entire Topic

Avatar

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

271 likes

Total Posts

320 posts

Correct Reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

271 likes

Total Posts

320 posts

Correct Reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
Anudeep_Garnepudi
MVP

09-12-2020

Hi @LaMind3 

There is no need to pass parameters to Sling Model, whatever you can get in HTL, you can get the same in Sling Model as well. If the values are hardcoded, directly hardcode in Sling Model itself.

Try this: <sly data-sly-use.slingmodel="${'com.myproj.core.models.TestSlingModel' @ fileReference ='/some/path/to/file' , imgParam='image'}" />

Model:

@Inject

String fileReference;

@Inject

String imgParam;

AG