Search code examples
adobeaem

CQ5 Using Client Libraries (CQ5.3)


I'm again coming up against problems after picking up some tasks on CQ 5.3 but having used nothing but 5.6 before this.

My problem is with client libraries:

In CRXDE Lite in CQ 5.3 I went and set up my client libraries as I normally would at component level and /etc/designs/<project> level (using type cq:ClientLibraryFolder), however after including the line <cq:includeClientLib css="my.category"/> I got a jsp error stating the tag was not defined.

Sure enough, after a quick Google I found this tag wasn't introduced until 5.4, so my question(s) are:

  1. How do you use client libraries in CQ 5.3?
  2. If the answer to #1 is "you can't" then why on earth is the option available to set them up present in 5.3 CRXDE Lite?

Internet searches have turned up no information (or I'm searching for the wrong thing), hence my question here.

Thanks in advance


Solution

  • Yes, the cq:includeClientLib tag was introduced in 5.4 only.

    But even without that you can include your clientlibs using the com.day.cq.widget.HtmlLibraryManager service.

    The tag was just a convenience wrapper around this service interface.

    HtmlLibraryManager htmlMgr = sling.getService(HtmlLibraryManager.class);
    if (htmlMgr != null) {
        htmlMgr.writeCssInclude(slingRequest, out, "my.category");
    }
    

    Refer HtmlLibraryManager API docs for the other methods that are provided.