gettting path of CSS / JS from clientLib category name programatically | Community
Skip to main content
New Participant
December 25, 2015
Solved

gettting path of CSS / JS from clientLib category name programatically

  • December 25, 2015
  • 4 replies
  • 1409 views

Hi all,

 
Hope everyone is doing fine !
 
In JSP usually if we have to include clientLib then we use below statement
<cq:includeClientLib js="personalization.ui"/>
 
And then these gets translated to actual script tags
<script type="text/javascript" src="/etc/clientlibs/personalization.js"></script>
 
Is there any way to get the path of JS referred by the clientLib category name using code ?
 
ie., I pass "personalization.ui" and it returns me back "/etc/clientlibs/personalization.js"
 
We have to do some further processing on this JS path so we need this.

 

Thanks in advance.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Kunal_Gaba_

You can use the HtmlLibraryManager API to get the path of the JS from the client lib name.  

First get the ClientLibrary by passing the category name in the below API method-

https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/widget/HtmlLibraryManager.html#getLibraries(java.lang.String[], com.day.cq.widget.LibraryType, boolean, boolean)

And then get the include path of the JS by calling the following API method-

https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/widget/ClientLibrary.html#getIncludePath(com.day.cq.widget.LibraryType)

4 replies

Kunal_Gaba_
Kunal_Gaba_Accepted solution
New Participant
December 26, 2015

You can use the HtmlLibraryManager API to get the path of the JS from the client lib name.  

First get the ClientLibrary by passing the category name in the below API method-

https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/widget/HtmlLibraryManager.html#getLibraries(java.lang.String[], com.day.cq.widget.LibraryType, boolean, boolean)

And then get the include path of the JS by calling the following API method-

https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/widget/ClientLibrary.html#getIncludePath(com.day.cq.widget.LibraryType)

edubey
New Participant
December 26, 2015

If these are your client library then you already know where they exist and there position will not change (unless you forcefully do) and if there are OOTB, their location will never be changed.

If would be great, if you can provide more insight of use case...

New Participant
December 26, 2015

Hi edubey,

Thanks for looking into it.

We need to pass the JS path to resource resolver to get final JS path

resourceResolver.map(request,jsPath) 

edubey
New Participant
December 26, 2015

Can you share your use case.....I mean what you are trying to achieve using JS Path?