Passing parameter from one component to other component | Community
Skip to main content
New Participant
March 4, 2024
Solved

Passing parameter from one component to other component

  • March 4, 2024
  • 3 replies
  • 821 views

Hello Everyone,

 

This is part of dynamicComponent.html component. Calling other component: helloworld by passing the param.

<div data-sly-resource="${ 'sample' @ resourceType='abc/components/helloworld', appendPath='/*', decorationTagName='div',
cssClassName='new section aem-Grid-newComponent',param='testParam'}"
data-sly-test="${(wcmmode.edit || wcmmode.preview) }"></div>

 

So, in hellowowrld.html, how can I get the param value?

Similarly, how can i pass the param in data-sly-include case?

 

Thanks

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 Kamal_Kishor

@mahesh_gunaje : With data-sly-resource you may not be able to pass any custom param. If this 'testParam' is going to be static or limited values, you can make use of selectors to do this. In your helloworld component, you can create a htl file such as helloworld.testParam.html and call your helloworld as below.

<div data-sly-resource="${ 'helloworld' @ resourceType='abc/components/helloworld', selectors='testParam' }"></div>

 

Please refer: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/extra-parameters-in-data-sly-resource/m-p/230010

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/data-sly-resource-attributes/m-p/210945

thanks.

3 replies

arunpatidar
New Participant
March 4, 2024

Hi @mahesh_gunaje 
You can only pass param to java use api but not when including the resources, you need to rethink the design

https://github.com/arunpatidar02/aem63app-repo/blob/master/java/ParamModel.java 

Arun Patidar
Imran__Khan
New Participant
March 4, 2024

@mahesh_gunaje Please check HTL specification https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#229-resource

You can't pass parameters but you can add selectors.

Kamal_Kishor
Kamal_KishorAccepted solution
New Participant
March 4, 2024

@mahesh_gunaje : With data-sly-resource you may not be able to pass any custom param. If this 'testParam' is going to be static or limited values, you can make use of selectors to do this. In your helloworld component, you can create a htl file such as helloworld.testParam.html and call your helloworld as below.

<div data-sly-resource="${ 'helloworld' @ resourceType='abc/components/helloworld', selectors='testParam' }"></div>

 

Please refer: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/extra-parameters-in-data-sly-resource/m-p/230010

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/data-sly-resource-attributes/m-p/210945

thanks.