How to pass parameters to Sling Modal from Sightly Component | Community
Skip to main content
Level 3
June 8, 2017
Solved

How to pass parameters to Sling Modal from Sightly Component

  • June 8, 2017
  • 16 replies
  • 29773 views

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.
Best answer by Eakambaram

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

Feike_Visser1
Adobe Employee
Adobe Employee
June 8, 2017

Have your slingmodel be adaptable from slinghttpservlet request.

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

Level 3
June 8, 2017

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?

Feike_Visser1
Adobe Employee
Adobe Employee
June 8, 2017

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

VeenaVikraman
Community Advisor
Community Advisor
June 8, 2017

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

smacdonald2008
Level 10
June 9, 2017

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

EakambaramAuthorAccepted solution
Level 3
June 21, 2017

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.

Level 5
November 5, 2017

Hi Eakambaram:

I have the same issue, not sure if you can help me.

for @Model({adaptables=Resource.class, adaptables=SlingHttpServletRequest.class), where to close '}'. Can you share a little bit code snippet.

Appreicated.

Thanks

smacdonald2008
Level 10
November 5, 2017

Newer article that uses Sling Models and @ inject Creating a custom Touch UI Grid Component for Adobe Experience Manager

Level 5
November 5, 2017

Thank you.

However, these examples are too simple. Do you have some more examples, which adaptable resource, and inject the request? or can adaptable request and resource both?

Feike_Visser1
Adobe Employee
Adobe Employee
November 5, 2017

You adapt always from *one* class. In case you adapt from request, you have the resource too via the getResource()