Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

generating clientlib from java


Level 3

Hi Guys,

I'm trying to add clientlibs from my java class into my template component:

<sly data-sly-use.css="${'getCSS' }" > <sly data-sly-use.clientLib="${'/libs/granite/sightly/templates/clientlib.html'}"> <clientlib data-sly-call="${clientLib.css @ categories=[css.clientlibname]}" data-sly-unwrap/> </sly> </sly>
getCSS.java public class getCSS extends WCMUsePojo{ private String clientlibname; public String getClientlibname(){     return clientlibname; } @Override     public void activate() throws Exception {         clientlibname = "geometrixx-main";     } } css.clientlibname is having my clientlib name which is coming from my getCSS.java , but on my page this CSS is not applying.

I tried to put entire line 

<clientlib data-sly-call="${clientLib.css @ categories=[css.clientlibname]}" data-sly-unwrap/> into clientlibName from java and tried to put css.clientlibname in my page but that only print out the entire syntax on page instead of applying the css:
<clientlib data-sly-call="${clientLib.css @ categories=['geometrixx-main']}" data-sly-unwrap/> </sly>

Please let me know if anyone has a reply for this.

1 Reply


Level 4


Out of curiosity: would this work after dispatcher/apache started to cache the generated .html?

I mean: is this "dynamic library selection" based on something like a sling selector?
Otherwise, I think even if you fix the current issue, you'll face a cache issue later.