Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Categories object not populated when using com.adobe.cq.wcm.core.components.models.ClientLibraries. #1808

Closed
gmartinelo opened this issue Aug 31, 2021 · 5 comments · Fixed by #2570
Labels
bug Unexpected problem or unintended behavior that impairs normal functioning of the product.
Milestone

Comments

@gmartinelo
Copy link

Bug Report

Current Behavior

The 'categories' property never gets populated with the desired values in the model and it seems to be instanciated with an object of type com.day.cq.i18n.

I'm following this documentation:
https://experienceleague.adobe.com/docs/experience-manager-core-components/using/developing/including-clientlibs.html?lang=en

<sly data-sly-use.clientlibs="${'com.adobe.cq.wcm.core.components.models.ClientLibraries' @ categories='otf.vanilla.homepage', async=true}"> ${clientlibs.jsIncludes @ context="unsafe"} </sly>

The resourceTypes property seems to have the same behavior described previously. Async, defer, crossorigin,media and onload are populated correctly.

Expected behavior/code
Categories object should have the values passed from HTL.

Environment

  • AEM version and patch level: 6.5.8
  • Core Components version: 2.17.8
  • JRE version: Java(TM) SE Runtime Environment 18.9 (build 11.0.10+8-LTS-162)

Additional context / Screenshots
Page.html
image

ClientLibrariesImpl.java
image

image

image

@Jdruwe
Copy link

Jdruwe commented Sep 24, 2021

I am seeing the exact same behaviour, this is not working indeed. Was trying something similar as described here: https://github.com/adobe/aem-core-wcm-components/blob/9dd529595b65a8441bd320b602584c2d568b6361/extensions/amp/README.md

<style amp-custom data-sly-use.clientlibs="${'com.adobe.cq.wcm.core.components.models.ClientLibraries' @ categories='cmp-examples.base.amp'}"> ${clientlibs.cssInline @ context="unsafe"} </style>

@ky940819
Copy link
Contributor

ky940819 commented Oct 2, 2021

I see the same issue when the named property is not set in data-sly-call attributes.

For example, the code posted above works properly for me (insofar as it properly sets the categories field in the model); however the resourceTypes field just has some other object injected. In my case that is the ReferrerFilter.ConfigurationPrinter.

If I change the htl to set the resourceTypes attribute but not the categories attribute, then the categories field in the model has a seemingly random object injected.

My suspicion is that since both the categories and resourceTypes field types are Object, it might just be sticking in something / anything / whatever is at the top of some list. Since the field type is Object it can stick anything in there.

This might be an issue for Sling, to make sure that an object isn't injected unless the name matches - even if the object type is compatible with something else.

This is all just speculation, I didn't step through the entire field injection resolution.

That said, changing the @Inject annotation in ClientLibrariesImpl resolves the random object injection in my tests.
Example:

public class ClientLibrariesImpl implements ClientLibraries {

    // ....

    @RequestAttribute(injectionStrategy = InjectionStrategy.OPTIONAL, name = OPTION_RESOURCE_TYPES)
    Object resourceTypes;

    // ....

    @RequestAttribute(injectionStrategy = InjectionStrategy.OPTIONAL, name = OPTION_CATEGORIES)
    private Object categories;

    // ....
}

@gmartinelo, do those changes resolve your issue?

@gmartinelo
Copy link
Author

@ky940819 sorry for the late response. Yes, I see the right object in the model with those changes. Thank you.

@gabrielwalt gabrielwalt added this to the Minor milestone Nov 19, 2021
@gabrielwalt gabrielwalt added the bug Unexpected problem or unintended behavior that impairs normal functioning of the product. label Nov 19, 2021
@gunakar89
Copy link

gunakar89 commented Aug 4, 2022

This is still not working! I always see this in the logs - "No categories detected. Please either specify the categories as a CSV string or a set of resource types for looking them up!" even when passing the right category from HTL

@shajiahmed
Copy link

shajiahmed commented May 16, 2023

I still see this issue. My environment is as follows
Archetype:41
AEM 6.5.15
AEM core components 2.22.0
Any update on this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected problem or unintended behavior that impairs normal functioning of the product.
Projects
None yet
7 participants