Saturday, 4 February 2017

Adobe Experience Manager FAQs and other Tips

This post captures FAQs, and other tips for AEM that AEM Developers will find useful. We will update this list on an on-going basis.

I  am using AEM Forms,not AEM Sites

See these docs:

Can I use @Reference in an HTL Class that extends WCMUsePojo

You cannot use the @Reference annotation from a HTL class that extends WCMUsePojo. This can be used from a Java class that uses @Service to reference another service known as dependency injection. To learn about Dependency Injection in AEM, see this article: 

Now to learn how to get a referenece to another AEM service from a class that extends WCMUsePojo, see this article: 

Can I use @Reference  from within a Sling Servlet

You can use Dependency Injection from within a Sling Servlet. See this community article/video. 

Can I manipulate the Touch UI Rich Text Editor using code

See this community article -

How can I programmatically retrieve HTML from an AEM page

See this great community article by Nolle Yolles:

What is cq.editconfig and when should i use it

Where do Lucene, Solr, ElasticSearch fit in the AEM Platform? 

Can i view an asset's metadata in CRXDE lite? 

Assume you have added metadata to a digital asset, as shown in this illustration. 

You can view the assets metadata by viewing a node named metadata under the asset in the AEM dam (/content/dam). For example, the above image is located here:


The metadata is stored as node properties as shown in this illustration.

Can I programmatically work with Coral UI object such as checkboxes?

Yes you can. It involves creating a JS script in an AEM Clientlib and then coding. See the reference documentation here:

Given this setup in CRXDE Lite: 

You can get a reference to this checkbox object in a clientlibs folder. The name of the clientlibs folder for Touch UI dialogs is cq.authoring.dialog ( this is talked about here.


(function ($, $document) {
    "use strict";


    $document.on("dialog-ready", function() {

        $('#kitten').attr('checked', true);     


})(jQuery, jQuery(document));

The result is the checkbox is checked via code: 

Note - we are planning on conducting a full session of AEM Ask the Community Experts on AEM Developing with the Coral API April 2017. 

Can i use OAuth in AEM? 

Need to search for special characters when searching JCR via JCR SQL2

Read this topic -- YOU  need to escape illegal JCR characters.

How can i work with custom JARs that are not in the Maven repository

You can place the JAR in your local Maven Repository and then reference it in your POM file. For example, to resolve myCustomJAR_1.0.0.jar within an AEM service, the myCustomJAR_1.0.0.jar file must be located in the Maven repository. You can upload the myCustomJAR_1.0.0.jar to Maven by using this Maven command: 

mvn install:install-file -Dfile=C:/plugins/myCustomJAR_1.0.0.jar -DartifactId=jrurbersrt1.0 -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true

Notice that you must specify the location of the myCustomJAR file in the -Dfile argument. Also notice that you specify the Dgroup and DartifactID values. Once you upload the JAR to Maven using this command, you can reference this JAR file using this Dependency.


Notice that scope element is system and systemPath references the location of the JAR file in the repository. (This dependency is used later in this article to build the AEM service) 

How can i work with 3rd party JARs when i create an OSGi bundle

When working with OSGi bundles that use 3rd party JARs (that are located in the Maven Repository), you can embed the 3rd party JAR (for example, Simple JSON JAR) into a separate bundle and deploy to AEM. See this community article/video for details.

Enable CORS Access-Control-Allow-Origin in AEM

If you use the default AEM JQuery, it has a token that lets you perform AJAX operations to AEM. 

AEM is experiencing slow page loading

How does Dispatcher Caching work

The dispatcher caches only files which have an extension; and the extensions which should be considered for caching can be configured in the dispatcher config as part of the caching rules.

So you need to add an extension to your service request (e.g. ".json"), and configure the dispatcher accordingly, then the caching will work.

 Capturing comments in a default email template used by an AEM 6.2 workflow

You can write a custom workflow step and inject values you want to populate into a email template with Java logic. For example: 

//Populate the MAP with the values 
 //Declare a MessageGateway service
 MessageGateway<HtmlEmail> messageGateway; 
 //Specify the EMail template 
 String template ="/etc/notification/email/html/";
 Resource templateRsrc = request.getResourceResolver().getResource(template);
 MailTemplate mailTemplate = MailTemplate.create(templateRsrc.getPath(), templateRsrc.getResourceResolver().adaptTo(Session.class));
 HtmlEmail email = mailTemplate.getEmail(StrLookup.mapLookup(myMap), HtmlEmail.class);

A solution without coding is to use the variable ${} in the default en.txt. To see other variables that can be used, see the Workflow Email Notification Service.


  1. This comment has been removed by a blog administrator.

  2. Regarding CORS, how AEM jQuery can help if the content hosted on AEM needs to be accessed by non AEM third-party?

    1. In this use case - we are assuming everything is in AEM - ie code in a component is making an AJAX request to a Sling Servlet