Adding custom JavaScript libraries to | Community
Skip to main content
roberth55706517
Level 4
October 7, 2016
Solved

Adding custom JavaScript libraries to

  • October 7, 2016
  • 14 replies
  • 16515 views

What I'd like to know is how to add custom clientlib script files to an adaptive form. Do I have to override the page component or can I just set the configuration to add the reference to the library when the page is built?

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 kautuk_sahni

Hi 

Please have a look at this Helpx article :- https://helpx.adobe.com/experience-manager/using/custom-carousel-components.html

// Creating Custom Carousel components for Adobe Experience Manager

Add the JQuery Carousel API to a CQ:ClientLibraryFolder node
You add CSS files and JQuery framework files to a cq:ClientLibraryFolder node to define the style of the client JSP.

To add CSS files and JQuery framework files to your component, add a cq:ClientLibraryFolder node to your component. After you create the node, set properties that allow the JSP script to find the CSS files and the JQuery library files.

To add the JQuery framework, add a new node named clientlibs to your component (as discussed later). Add these two properties to this node.

                
NameTypeValue
dependencies  String[]cq.jquery  
categories  String[]jquerysamples  

Read this article, this will help you.

 

Reference articles :- 

Link:- https://helpx.adobe.com/experience-manager/using/integrating-custom-cq-widgets-third-party.html

// Integrating custom Adobe Experience Manager Component with third-party libraries

 

I hope this would help you.

Thanks and Regards

Kautuk Sahni

14 replies

roberth55706517
Level 4
October 12, 2016

It looks like I may have solved my problem. Part of it may have been that after all of the changes, I hadn't published the form.

kautuk_sahni
Community Manager
kautuk_sahniCommunity ManagerAccepted solution
Community Manager
November 22, 2016

Hi 

Please have a look at this Helpx article :- https://helpx.adobe.com/experience-manager/using/custom-carousel-components.html

// Creating Custom Carousel components for Adobe Experience Manager

Add the JQuery Carousel API to a CQ:ClientLibraryFolder node
You add CSS files and JQuery framework files to a cq:ClientLibraryFolder node to define the style of the client JSP.

To add CSS files and JQuery framework files to your component, add a cq:ClientLibraryFolder node to your component. After you create the node, set properties that allow the JSP script to find the CSS files and the JQuery library files.

To add the JQuery framework, add a new node named clientlibs to your component (as discussed later). Add these two properties to this node.

                
NameTypeValue
dependencies  String[]cq.jquery  
categories  String[]jquerysamples  

Read this article, this will help you.

 

Reference articles :- 

Link:- https://helpx.adobe.com/experience-manager/using/integrating-custom-cq-widgets-third-party.html

// Integrating custom Adobe Experience Manager Component with third-party libraries

 

I hope this would help you.

Thanks and Regards

Kautuk Sahni

Kautuk Sahni
Level 3
November 22, 2016

The best documentation to look at before getting into the more complex samples is the overview of how ClientLibs are created and implemented here: https://docs.adobe.com/docs/en/aem/6-2/develop/the-basics/clientlibs.html. I highly recommend you try to implement client libs in a "hello world" example using lots of "console.log("");" in your own code to make sure the code is actually executing. I'd avoid implementing ClientLibs into forms until you've got the concept working outside in a simple page because errors and events that don't fire as part of a form can be "hidden" from you. When script fails in a rule for example, you won't necessarily see anything in the console log. With a plain JSP page for example, you'll see all your events and messages uninterrupted.

In regards to the client library field in the forms UI, the best way to get to this is to switch to your form component view where you can see all your panels and objects, click on the root panel, then click on the configure wheel that appears when the panel is selected. Alternatively (and more simply), switch to classic view and then edit the main panel.

Level 2
December 4, 2016

Hi,

Here are the detailed steps required to get this to work ...

  • In CRX DE, create a node of type sling:Folder under etc/designs folder, which I named same as my project
  • Under that folder create another node of type sling:Folder node named clientlibs
  • Under that folder, create a node of type cq:ClientLibraryFolder, which I named same as my form (if you have more than one form for this project, you would have a directory for each form under clientlibs parent folder).
  • On this node (of type cq:ClientLibraryFolder) add property 'categories' of type String[] (select String as Type and click on 'Multi' to make type a String array) and set value to your category name (this is the name you will set as value on 'Client Library Category' in your adaptive form).
  • Copy clientlib sub-directory structure from a working reference site, e.g. geometrixx-media, containing  cs.txt, js.txt and referenced 'css' and 'js' subfolders (make sure to save your changes to repository before copy and pasting to your newly created clientlib folder or you will get a 404 not found error).
  • Clean out unused css and js files and rename to your preference, then edit js.txt and css.txt to point to your renamed files.
  • To call your custom js function add function call to a rule defined on, e.g. a button on your adaptive form.