How to pass parameters to components? | Community
Skip to main content
eric_estes
Level 2
March 14, 2016

How to pass parameters to components?

  • March 14, 2016
  • 1 reply
  • 7837 views

I'm rendering out a component via a data-sly-resource and I'd like to be able to pass parameters as part of this, for example something like <sly data-sly-resource="${'featuredPost' @ showComments=false}"></sly> or something. I'd rather keep it out of the dialog because it's not something authors need to worry about and I'd rather not create separate resource types to handle different rendering scenarios for the same content. Is there a way to do this?

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

1 reply

smacdonald2008
Level 10
March 14, 2016

This is discussed here: 

http://blogs.adobe.com/experiencedelivers/experience-management/sightly-intro-part-3-2/

 

Use-api

In my second article I explained that you can call methods from your custom-classes via the data-sly-use notation.
In this example I will show that you can also pass in parameters from your components.

However - values are passed from front end to the back end - which is Java. 

If you want to get values to the component itself (ie - a String value)- you need to use a dialog. 

eric_estes
Level 2
March 14, 2016

smacdonald2008 wrote...

This is discussed here: 

http://blogs.adobe.com/experiencedelivers/experience-management/sightly-intro-part-3-2/

 

Use-api

In my second article I explained that you can call methods from your custom-classes via the data-sly-use notation.
In this example I will show that you can also pass in parameters from your components.

However - values are passed from front end to the back end - which is Java. 

If you want to get values to the component itself (ie - a String value)- you need to use a dialog. 

 

 

Looks like the method shown in that link would just pass parameters into the use file, which is called from within the component, and not into the component itself?

smacdonald2008
Level 10
March 14, 2016

Correct - that blog talks about getting values to the Java part of the Sightly code. 

The way to  get values passed to the Sightly component is to use a dialog and code like: 

<div id="experiencetext">${properties.contactDescription}</div>

See this Sightly article for more details: 

https://helpx.adobe.com/experience-manager/using/movie.html