Developers


Friends, this might be the most important post for all the developers out there. I am pretty sure these questions are at the tips of each interviewer and you will come across them definitely. Also read the interesting questions I would be posting in this blog.


Q1.) How to find out in which components a given xtype e.g. ‘checkbox’ is used in AEM (using an Xpath query – in CRXDE ) ?

You can use the XPATH query to achieve this:

/jcr:root/apps//element(*, cq:Widget)
[
@xtype = 'checkbox'
]

However there is catch in this, the question asks about the Component count using xtype=checkbox ,if more than one checkbox are used in same component, the count will increase. You may have to process the obtained result to get the exact count.


Q2.) What is a Felix console ?

Apache Felix “is a community effort to implement the OSGi R4 Service Platform, which includes the OSGi framework and standard services”.

OSGi is a fundamental element in the Technology stack of CQ5, and is used to control bundles and their configuration.

The Apache Felix Web Management Console offers a selection of tabs for controlling the OSGi bundles:

  • Bundles: used for installing bundles
  • Components: used for controlling the status of components required for CQ5
  • Configuration: used for configuring the OSGi bundles, and is therefore the underlying mechanism for configuring CQ system parameters

Important
Any changes made are immediately applied to the running system. No restart is required.

It can be accessed from ../system/console/components; for example http://localhost:4502/system/console/components.


Q3.) How can i find the page is in edit mode or design mode .. the jsp page

<%
boolean isEdit = WCMMode.fromRequest(request) == WCMMode.EDIT;
boolean isDesign = WCMMode.fromRequest(request) == WCMMode.DESIGN;
%><c:set var="isEdit" value="<%= isEdit %>" /><c:set var="isDesign" value="<%= isDesign %>" />

Q4.) What is Workflow exactly?

Web Content Management (CQ WCM) enables you to generate and publish pages to your website. This functionality is often subject to organizational processes, including steps such as approval and sign-off by various participants. These processes can be represented as workflows, which in turn can be defined within CQ, then applied to the appropriate content pages. Workflow is the series of activities that are necessary to complete a task.

Working with Workflows
Build Workflows 


Q5.) I want to put 1000 images in dam and want each images go through with workflow, how?

You can use Workflow launchers to achieve this. They are used to trigger CQ workflows based on node events in the Author/Publish environments. I would suggest in this case create a Launcher in Author environment and add the images in it and then after completion of all the triggered workflows , publish the content to respective Publish environments. The workflow launcher basically allows you to define the workflow to be launched if a specific type of node is created/modified/deleted. A default set of events have already been provided out of the box, thus the reason why everything seems automatic upon content generation

Read More


Q6.) What is Listener property in AEM?

In CQ you can associate a listener with a component, a dialog, a widget etc. For that you just need to create a folder with the name listeners as shown below.

Listeners are basically used for Dynamic dialogs and Simple Client Side verifications which can be added using some extjs code. They cover a variety of dialog events -beforeshow, loadcontent, beforesubmit etc. You may refer to Widget API  and search for ‘Public Events’ heading for various events associated with a particular node type.

To access widgets inside the event listeners of any widget, follow the below step.

  • Get the “dialog” object first.
var dailogObject = this.findParentByType('dialog');
  • This will return the dialog object associated with your compoent dialog. Then look for the corresponding widget by invoking .
var titleField = dailogObject .getField('./jcr:title');
  • The above function looks for a widget by name ‘./jcr:title’ and returns the widget object associated.

e.g.- use case 1: if author selects any link URL then the corresponding title of the page should be set into the TextField widget.

function(){
    var componentDialog = this.findParentByType('dialog'); 
// returns the dialog object
    var titleWidget = componentDialog.getField("./title");
    var selectedPath = this.value;
// returns the selected path from the path field
//Can write a remote service which returns the title of any path selected 
    $.get("/someRemoteService",{'path':selectedPath}).done(function(data){
       titleWidget.setValue( data );
    });
}

Q7.) How to restrict some script on publish instance ?

Obtain the value for the boolean variable as mentioned below-

boolean isEdit = WCMMode.fromRequest(request) == WCMMode.EDIT;

and include the script only when the above property is true .


Q8.) Describe the process for loading of assets in dam.

Digital Assets can be uploaded using the graphical user interface or WebDAV. When assets are uploaded, the metadata is extracted and brought into CQ5 DAM. Read the steps involved http://docs.adobe.com/docs/en/cq/current/dam/dam_upload_asset.html. There are few Workflows which get triggered at the time of Creation of Dam Assets. (e.g. Dam Update Asset for creating renditions.)


Q9.) How to build bundle through crxde – steps ?

You may create bundles using CQ5 crxde, but thats not advisable (See better way below). Go to the link below for the steps for creating Bundles-


Q10.) What are the typical steps for creating custom components?

Go through the blog post –http://teknopoint.us/creating-custom-component-with-custom-dailog/ where the steps are well explained graphically.


Q11.) What is the process to connect to an external database from AEM ?

Access an external SQL database to so that your CQ applications can interact with the data:

  1. Create or obtain an OSGi bundle that that exports the JDBC driver package.
  2. Configure a JDBC data source pool provider.
  3. Obtain a data source object and create the connection in your code.

More helpful Link


Q12.) What is iparsys and slingSuperResourcetype

Iparsys : The inherited paragraph system is a paragraph system that also allows you to inherit the created paragraphs from the parent. You add paragraphs to iparsys at for example, /content/geometrixx/en/products and as result, all the subpages of products that also have iparsys with the same name inherit the created paragraphs from the parent. On each level, you can add more paragraphs, which are then inherited by the children pages. You can also cancel paragraph inheritance at a level at any time.

Simply, iparsys is a parsys that inherits it’s content from the ancestor pages.

slingSuperResourcetype: It is used to inherit / extend components from foundation or other components. There is a good example to understand it completely. Consider components a , b, c, x, y with the below mentioned properties for each of them :

  • /
    • a
    • b
      • sling:resourceSuperType = a
    • c
      • sling:resourceSuperType = b
    • x
      • sling:resourceType = c
    • y
      • sling:resourceType = c
      • sling:resourceSuperType = a

The type hierarchy of

  • /x is [ c, b, a, <default>] while for
  • /y the hierarchy is [ c, a, <default>]

because /y has the sling:resourceSuperType property whereas /x does not and therefore its supertype is taken from its resource type.


Q13.) What is the difference between

 1. <c:import url="layout-link.jsp" />
 2. <sling:include path="layout-link.jsp" />
 3. <cq:include script="layout-link.jsp" />

1. <c:import url="layout-link.jsp" />

I assume this is the import tag of the Standard Tag Library. This tag is documented at http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/c/import.html and does not know about Sling directly.

But — asuming — this tag is using a RequestDispatcher to dispatch the request, this tag will also pass Sling and the Sling resource resolver.

2. <sling:include path="layout-link.jsp" />

This is the include tag of the Sling JSP Tag library. This tag knows about Sling and also supportsRequestDispatcherOptions.

3. <cq:include script="layout-link.jsp" />

This tag is Communiqué specific extension of the Sling JSP Tag library include tag. IIRC it supports callings scripts in addition to just including renderings of resources.

Advantage of each tag and Usage:

In a Communiqué application, I would suggest to generally use the Communiqué or Sling include tag since this provides you more Sling support.

You may use the JSTL import tag if you don’t have specific requirements for Sling extended features, plan to use the JSP (fragment) outside of Communiqué or if you want to further process the generated (imported) content with a reader or a variable.

In the future, it is conceivable that the Sling and/or Communique tag library will also provide an import tag similar to the JSTL import tag to be able to further process the imported result.


Q14.) What is the difference between cq:include and sling:include ?

<%@ include file="myScript.jsp" %>

This line of code will tell the JSP compiler to include a complete file (namely,myScript.jsp) into the current file at compilation time, just as if the contents of the included file were pasted directly into the original file.

In the Day Communiqué runtime environment, it’s also possible to achieve this using a syntax of:

<cq:include script="myScript.jsp" />

The difference in this case is that the included file gets pulled in at runtime, rather than at servlet compile time. (above).

<% sling.include("/content/mypath/mynode") %>

This line of code relies on the sling convenience object, which has an include() method. What’s happening here is that you’re essentially telling Sling to render the node “mynode” using whatever script Sling can find for that node based on the node’s sling:resourceType. The rendered version of the node’s content is what gets inserted into the original file.

The sling.include() technique is very powerful. It not only lets you include programmatically rendered content into a file at runtime, but because it’s scriptable, you can use sling.include() to conditionally pull content into a page (which is not true of the other inclusion techniques described above).

<%
    if ( sling.getRequest().getHeader("User-agent").indexOf("Firefox") != -1 )
        sling.include("/content/test/myhead.iframe");
    else
        sling.include("/content/test/myhead.h1"); 
%> 

**Note- As sling include is scriptable, you can include the path as a variable too.

Q15.) What is the purpose of Activator.java file?

The Activator.java file is the optional listener class to be notified whenever there is an event of bundle start and stop . It implements BundleActivator and has two methods as follows:

  • public void start(BundleContext context) To add initialization code or logs
  • public void stop(BundleContext context) To add cleanup code or logs

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 ?
      Thanks
      Hashim

      Like

  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

    Like

      • 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!

        Like

        • 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.

          Like

Leave a reply to Sachin Gupta Cancel reply