How to pass parameters to Sling Modal from Sightly Component | Community
Skip to main content
Level 3
Jun 8, 2017 4:42 PM UTC
Solved

How to pass parameters to Sling Modal from Sightly Component

Hi ,

I am trying to pass some custom parameters from my Sightly Component to Sling Model. But I am not able to read those passed parameters inside my Sling Model.

Below is my sightly code :

<sly data-sly-use.mySlingModal="${'com.adobe.website.models.ImageModel' @ colour='red', path=resource.path}"></sly>

How to read color and path in side my sling model java class.

Can you please help me in solving this.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
EakambaramAccepted solution
Level 3
Jun 21, 2017 9:16 PM UTC

Thank you all for responding. We  have solved it as below.

@Model({adaptables=Resource.class, adaptables=SlingHttpServletRequest.class)

So that at the same time I will get my resource/Node/Content properties and the values passed to my sling modal from my sightly component.

16 replies

EakambaramAuthorAccepted solution
Level 3
Jun 21, 2017 9:16 PM UTC

Thank you all for responding. We  have solved it as below.

@Model({adaptables=Resource.class, adaptables=SlingHttpServletRequest.class)

So that at the same time I will get my resource/Node/Content properties and the values passed to my sling modal from my sightly component.

Translate
smacdonald2008
Level 10
Jun 9, 2017 3:24 PM UTC

We show use of HTL and Sling Models in this article -- Developing your first Experience Manager 6.3 Components

Translate
VeenaVikraman
New Participant
Jun 8, 2017 9:17 PM UTC

Hi Eakambaram

     I hope you have read this blog HTL introduction part 4   . Feike Visser​ has put across the details here. Please check the Sling Model Section and check if this is what you are looking for

Thanks

Veena

Translate
Feike_Visser1
Employee
Jun 8, 2017 8:47 PM UTC

What do you mean? @ inject should be available..

Translate
Level 3
Jun 8, 2017 8:29 PM UTC

I tried to use @Inject. But I am not able to use @Inject as I am using a different version. Apart form  @Inject do we have any other annotation for reading the parameters passed?

Translate
Feike_Visser1
Employee
Jun 8, 2017 7:51 PM UTC

Have your slingmodel be adaptable from slinghttpservlet request.

Then add two properties (colour , path), with the @inject annotation.

Translate