adobe / aem-core-wcm-components

Standardized components to build websites with AEM.
https://docs.adobe.com/content/help/en/experience-manager-core-components/using/introduction.html
Apache License 2.0
732 stars 742 forks source link

Document extending Data Layer with custom data (while retaining OOTB data) #1440

Open davidjgonzalez opened 3 years ago

davidjgonzalez commented 3 years ago

Feature Request

Is your feature request related to a problem? Please describe.

Can you please document with code samples how to properly extend the provided data layer objects (for any .asXXX(..)) with custom data key/values?

I don't see this documented in this Git repo or on Adobe Documentation. The solution here: https://experienceleague.adobe.com/docs/experience-manager-learn/sites/integrations/adobe-client-data-layer/data-layer-customize.html?lang=en#sling-model is copy-down code, and "works around" the provided Java APIs (and looks like has the opportunity to lose the OOTB data points)

These docs https://experienceleague.adobe.com/docs/experience-manager-core-components/using/developing/data-layer/extending.html?lang=en#developing imply we can provide a custom XxxData object, but I'm not clear how that would actually work given the public APIs.

Describe the solution you'd like

Add documentation on how to add custom data layer key/values to the resulting JSON object to the README: https://github.com/adobe/aem-core-wcm-components/blob/master/DATA_LAYER_INTEGRATION.md

Documentation

Something like the following code snippet, but show how/which methods to call and pass in custom data.

...
 @Override
    @NotNull
    protected ComponentData getComponentData() {
        return DataLayerBuilder.extending(super.getComponentData()).asComponent()
            .withTitle(this::getText)
            .withLinkUrl(this::getLinkURL)
            .build();
    }
Thepriestdude commented 2 years ago

Are there any updates to this? Our team needs to extend the data layer as well, but we can't find any documentation on how to do it, but rather just copy-down and "work arounds" as @davidjgonzalez also mentioned.