Expand my Community achievements bar.

SOLVED

Passing parameters to Component

Avatar

Level 5

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

1 Accepted Solution

Avatar

Correct answer by
Level 10

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

View solution in original post

6 Replies

Avatar

Level 10

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

Avatar

Level 10

Hi Dean,

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

Avatar

Level 9

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

Avatar

Correct answer by
Level 10

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

Avatar

Administrator

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

Avatar

Level 5

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