Passing parameters to Component | Community
Skip to main content
Level 4
February 2, 2016
Solved

Passing parameters to Component

  • February 2, 2016
  • 6 replies
  • 2098 views

Is it possible to pass parameters to a component?

I have a situation where I want to configure a component but do not want the author to do so.  Therefore, I'd like to be able to pass parameters to a component.

Is it possible?

Does anyone have an example of that?

Thank you in advance for your help.

-Dean

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 Lokesh_Shivalingaiah

Hi Dean,

There can be 2 types of components

Authoring or static component -  in which you would need some input from the author to get the content and render the in HTML/JSP

Dynamic component - No authoring content required, component will render the content from internal (OSGi) service or an external REST service in which you can pass some parameters and get the content accordingly.

Not sure exactly if this answer your question. If not, please let us know you requirement with little more detail so that we can suggest accordingly

6 replies

smacdonald2008
Level 10
February 2, 2016

The best practice in AEM is for an author to set values in a component dialog. 

Another  way I can think of that involves a component that uses an OSGi service. You can set values used by the OSGi service as configuration values. THat way- you can set values in the AEM JCR that can be used by a component. 

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

edubey
Level 10
February 2, 2016

Hi Dean,

Can you please elaborate your use case a bit more with examples

Jitendra_S_Toma
Level 10
February 3, 2016

Hi,

I am curious to know a few things:

  • What do mean by passing parameters to a component?. Do you want to pass parameters in sling include?.
  • Even if the author wants to pass parameter to a component. How authors can do so?.

Jitendra

Lokesh_Shivalingaiah
Lokesh_ShivalingaiahAccepted solution
Level 10
February 3, 2016

Hi Dean,

There can be 2 types of components

Authoring or static component -  in which you would need some input from the author to get the content and render the in HTML/JSP

Dynamic component - No authoring content required, component will render the content from internal (OSGi) service or an external REST service in which you can pass some parameters and get the content accordingly.

Not sure exactly if this answer your question. If not, please let us know you requirement with little more detail so that we can suggest accordingly

kautuk_sahni
Community Manager
Community Manager
February 3, 2016

Hi 

As mentioned by others, could you please elaborate your use-case.

Is it following things that you would like :

1. Client to set some parameters that component will caters ? [That can be achieve by creating Restful service. You can create a Component that would respond to you with your result. Call it using AJEX with query parameters and header to get response. You can also use authentication to only respond to valid queries].

2. Component to Component communication ? [Solution:- http://www.code-tool.com/questions/34989384/best-way-of-aem-6-1-inter-component-communication ]

3. Or do you want a component that should not take any value from dialog box and should take value from OSGI ? [Create a component with a desired dialog box(minimal) and let component communicate with JCR (read/modify/create nodes) and then shape up your component accordingely].

 

Reference Article :- https://helpx.adobe.com/experience-manager/using/uploading-files-aem1.html [Custom Uploading Component, this will tell you about POST/GET request handling by compoent] .

I hope this helps you.

Thanks and Regards

Kautuk Sahni

Kautuk Sahni
Level 4
February 3, 2016

This is exactly what I was looking for.  My apologies for not providing enough information to begin with.

Thank you all for taking the time to reply.

-Dean