Closed gmartinelo closed 1 year ago
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>
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?
@ky940819 sorry for the late response. Yes, I see the right object in the model with those changes. Thank you.
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
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
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
Additional context / Screenshots Page.html
ClientLibrariesImpl.java