Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Sharing data between components

Avatar

Level 7

Hi Team,

 

Is there a way to share the data between components without using model class or servlet ?

 

Thanks 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @JakeCham 

It totally depends on the use case:

Case I:

For sharing the data between the component if your use case is with that the component can be CSR (client side rendered), then in that case you can create the WebComponent with the libraries using as React, etc which manages the state.

 

Using the webpack or gulp then you can create the minified javascript for the same. Once the javascript file is created use this along with the clientlibs for your existing site.

Now as this is a web component and it is CSR, so your should be able to pass the data within.

Case II:

If your components are totally based on the HTL/Sightly then javascript has to be written to read the data or write the data directly in to the DOM or one can use the input hidden values for achieving this.

Hope this helps!

Thanks

View solution in original post

2 Replies

Avatar

Community Advisor

Yes, you can but it depends on the use case.

Could you please explain use case here?



Arun Patidar

Avatar

Correct answer by
Community Advisor

Hi @JakeCham 

It totally depends on the use case:

Case I:

For sharing the data between the component if your use case is with that the component can be CSR (client side rendered), then in that case you can create the WebComponent with the libraries using as React, etc which manages the state.

 

Using the webpack or gulp then you can create the minified javascript for the same. Once the javascript file is created use this along with the clientlibs for your existing site.

Now as this is a web component and it is CSR, so your should be able to pass the data within.

Case II:

If your components are totally based on the HTL/Sightly then javascript has to be written to read the data or write the data directly in to the DOM or one can use the input hidden values for achieving this.

Hope this helps!

Thanks