BindingValueProvider & BindingValueProviderByContext Use these to get common data from Page property
Hi All,
I am trying to implement some components which reads common page property and resolve a referenced content fragment and read data from it which again is shared across many components on page. To solve this problem, I can think of below approaches.
- Read this data again and again in my model class which does not seem optimal as I am reading this same data in many components.
- Set values in sling request attributes which is possible solution, but I don't like this approach. AEM: Sharing Data Between Components (alexlockhart.me)
- I am curious if I can just implement a BindingValueProvider so this property can be accessed directly in my HTL code similar to how other properties like ${currentPage}, ${properties} object is used. I like this approach but I am worried that this might cause some performance issues. I have found some sample code as below acs-aem-commons/bundle/src/main/java/com/adobe/acs/commons/wcm/properties/shared/impl/SharedComponentPropertiesBindingsValuesProvider.java at master · Adobe-Consulting-Services/acs-aem-commons · GitHub but not sure if that is correct way to implement it now I also see BindingValueProviderByContext which Ideally should be used.
If anyone has experience and have used these and also have some sample code, they can share would be great.
Thank you for your help.
Thanks,
Shehjad