Q31.) How do you convert a class to a service ?

You may use Sling Annotations to do so :

import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.felix.scr.annotations.Reference;


 public class SampleServiceImpl implements SampleService {

     private SlingRepository repository;

Note: The SCR annotations are deprecated in the latest builds of Apache Felix.

Q32.) Inheritance in CQ at component  level ?

Components within AEM are subject to 3 different hierarchies:

  • Resource Type Hierarchy:
    This is used to extend components using the property sling:resourceSuperType. This enables the component to inherit; for example a text component will inherit various attributes from the standard component.

    • scripts (resolved by Sling)
    • dialogs
    • descriptions (including thumbnail images, icons, etc)
  • Container Hierarchy :
    This is used to populate configuration settings to the child component and is most commonly used in a parsys scenario.
    For example, configuration settings for the edit bar buttons, control set layout (editbars, rollover), dialog layout (inline, floating) can be defined on the parent component and propagated to the child components.
    Configuration settings (related to edit functionality) in cq:editConfig and cq:childEditConfig are propagated.
  • Include Hierarchy
    This is imposed at runtime by the sequence of includes.
    This hierarchy is used by the Designer, which in turn acts as the base for various design aspects of the rendering; including layout information, css information, the available components in a parsys among others.

Q33.) How to add the tab in the Page Properties dialog?

In order to achieve this , you may follow the below steps:

  1. Copy /libs/foundation/components/page/dialog node to your template’s component that you want to add dialog properties to.
  2. Add fields to the dialog

e.g. If you had a page component /apps/<myapp>/components/pages/contentpage that has sling:resourceSuperType=/libs/foundation/components/page then you would copy/libs/foundation/components/page/dialog to /apps/<myapp>/components/pages/contentpage/ to make an overlaid dialog

Q34.) Under page properties, basic tab, what is the use of On time and Off time?

This will trigger automatic replication (to activate or deactivate a page as appropriate) when the ontimes or offtimes defined for a page occur. This is primarily used for Dispatcher Flush agents.

On Time
The date and time at which the published page will be activated. When published this page will be kept dormant until the specified time. Leave these fields empty for pages you want to publish immediately (the normal scenario).

Off Time
The time at which the published page will be deactivated. Again leave these fields empty for pages you want to publish immediately.

Q35.) How to Convert a jar File into an OSGi Bundle?

There is a plugin available in Eclipse to do so. Other methods could also be used.

Convert a Jar into Osgi-jar    Other link
Create an OSGI bundle

Q36.) How to render renditions for images dynamically ?

While uploading an asset in CQ5, various renditions are created by default. They can be defined as per need of the project and can be called . Another approach to render the images dynamically would be to use selectors. The complete process is very well explained in the blog below :

Q37.) What happens when a file is Uploaded in CQ5?

Q38.) How can we create Custom Tag-Libs for CQ?

This blog defines how to proceed for this

Q39.) How to upgrade from  5.6 from 5.3/5.4/5.5?

You can check out the documentation for the steps involved in upgrading , as per provided by Adobe. The steps might change depending on the version of the CQ5

Q40.) How to create custom xtype multi textfield, pathfield, new window options?

The below blog defines the procedure to do so in detail:

Q41.) What does adaptTo() method do ?

Sling offers an Adapter pattern to conveniently translate objects that implement the Adaptable interface. This interface provides a generic adaptTo() method that will translate the object to the class type being passed as the argument.

For example to translate a Resource object to the corresponding Node object, you can simply do:

Node node = resource.adaptTo(Node.class);

Read More
Other link

Q42.) Which one to use JCR API V/s Sling API?

CQ5 as a complex framework is built on top of various other frameworks, on the server-side the most notably ones are JCR (with its implementation Apache Jackrabbit) and Apache Sling. Both are very powerful frameworks, but both of them have some overlap in functionality:

In these 2 areas you can work with both frameworks, and achieve good results with both. So, the question is, in what situation should you prefer Sling and in what situation pure JCR.

While on pure JCR you only work with raw repository structures (nodes and properties), the Sling resource abstraction offers you easier handling (no need to deal with the repository exceptions any more) and much more options to interact with you business objects and services.

Let me explain via example: let’s assume, that we need to read the title of CQ page


String readTitle (Session session) {
  Node page = session.getNode("/content/geometrixx/en/services");
  Node jcrcontent = page.getChild("jcr:content");
  Property titleProp= jcrcontent.getProperty ("title"):
  String title = titleProp.getValue().getString();
  return title;

 Sling API

String readTitle (ResourceResolver resolver) {
  Resource r = resolver.getResource(/content/geometrixx/en/services");
  Page page = r.adaptTo(Page.class);
  String title = page.getTitle();
  return title;

Problems with JCR API in above example:

  • We need to know, that all CQ page properties are stored on the jcr:content node below the page
  • the title of the page is encoded in the property “title”.
  • Properties are not available immediately as basic types, and need to be converted from Properties to a Value to our expected type (String)

We don’t need to deal with the low-level information (like the jcr:content node) and properties, but we use the appropriate business object (a CQ page object), which is available out of the box and offers a better level of abstraction.

On a Sling resource level we also a bunch of helpers available, which offer some great benefits over the use of plain nodes and properties. (adaptTo(), ValueMap, etc)

Read More 

Q43.) What is a FileVault?

The FileVault tool (VLT) is a tool developed by Adobe that maps the content of a CRX/CQ instance to your file system. The VLT tool has similar functions as source control system client (such as a Subversion (SVN) client), providing normal check-in, check-out and management operations, as well as configuration options for flexible representation of the project content.

You run the VLT tool from the command line. This document describes how to use the tool, including how to get started and get help, as well as a list of all commands and available options.

Read More in Details


19 thoughts on “Developers

  1. Pingback: How to Prepare ? – CQ5 AEM Tricks of Trade

    • Hi, A design dialog is specific to the design of a particular template. You can access the properties as long as its for a particular template. What role does SDI has in this? Can you please explain the use case in more detail. What are you trying to achieve ?


  2. Hi Hashim,
    I am facing a problem, please help me to resolve it.
    1. I have created a page from site admin.
    2. Now I go to CRX and rename the name of that node from content folder which belongs to that page.
    3. And then after I go to siteadmin and try deleting that page. I am unable to delete that page now.

    Please help why it is happening and how can i fix?

    Thanks- Rashid


      • Yes, First I refresh teh siteadmin page and find the changes here(change in page name). Now from site admin itself I am try to delete my site page.

        I tried same with vanilla instance and found it is working. Thank You!


        • If its working in Vanilla instance with same steps, then you might have configured something in Siteadmin console. Could you check the JS errors in Console and Errors in Logs to narrow down the issue.


Leave a Reply to Hashim Khan Cancel reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s