Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Passing parameter from one component to other component

Avatar

Level 8

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@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-s...

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/data-sly-resource-attribut...

thanks.

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

@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-s...

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/data-sly-resource-attribut...

thanks.

Avatar

Community Advisor

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