Posts Tagged ‘Adobe CQ’


This article explains how to create an application/project in AEM using CRXDE Lite. The application/project is an area where we build the AEM elements (Templates, Components, etc.). To successfully complete and understand these instructions, you will need a running CQ5 Author instance

What is CRXDE Lite?

CRXDE Lite comes out of the box, and is embedded into Adobe Experience Manager. It enables us to perform standard development tasks in the browser. With CRXDE Lite, we can create different AEM projects, create and edit jsp, html, java files, folders, templates, components, dialogs, nodes, properties and bundles while logging and integrating with SVN.

What is an application/project?

An application/project  in AEM is where we store all the AEM elements such as Templates, Components, , and static files such as CSS, JS, etc. To start a new application/ project, it is necessary to define a location for these elements. In general, they are created as a sub folder of the /apps folder. It is recommended that we create the following structure for our application/project:

/apps/<our application name>   –  The Application / Project

/apps/<our application name>/ components    –  All the AEM Components go here.

/apps/<our application name>/ components/page  – All the page components go here

/apps/<our application name>/ components/global  -All the Global components go here

/apps/<our application name>/templates – All the Templates should go here.

/apps/<our application name>/src  –  All the OSGi bundles should go here.

/apps/<our application name>/install   –  All the Compiled OSGi bundles should go here.

Create Application / Project:

1. Right-click on the apps folder and then select Create -> Create Folder

2. A new dialog box opens where we need to enter the folder name. This will be your project name

3. Create structure as mentioned above, like templates, components, etc.

4. Click Save. Note that without clicking on the saving button, the existing changes wouldn’t be saved.

5. Congratulations! You have successfully created an application/project and related structure in AEM

screen-shot-2017-02-16-at-11-57-17-am

Apache Sling is one of the core technologies used in Adobe Experience Manager (formerly known as Adobe CQ / Day CQ).

Sling started as an internal project at Day Software, and taken up by Apache in September 2007. It’s the reason why some bundles/libraries are named like com.day.

The other important technologies include Apache Jackrabbit, Apache Felix, OSGi. We will discuss about the Apache Sling in this article, and how to create a sample content and consume it.

Apache Sling is a web framework that uses a Java Content Repository (like Apache Jackrabbit) to store and manage content. Sling applications use either scripts or Java servlets to process HTTP requests in a RESTful way.

Sling in very simple terms could be described as a REST API for JCR. We can use http requests to manage content inside the repository. Sling provides a mechanism to render that content in different ways. We can use JSP, ESP scripts, Java (servlets, pojos, etc) in the Felix container to process requests and deliver content.

When a request is made for a particular node, Sling looks up for a property called sling:resourceType. This is used to look up the rendering scripts for the requested resource.

Apache Sling is:

  • a REST based web framework
  • Content-driven, using JCR
  • Powered by OSGi framework
  • an Apache Open Source project

We shall see an example of how to start, create node and read the node’s content from Sling.

  1. Download Apache Sling Launchpad self-runnable jar from https://sling.apache.org/downloads.cgi. In my case, I have downloaded the latest jar org.apache.sling.launchpad-8.jar
  2. After the jar is downloaded, just start it as follows:
    java -jar org.apache.sling.launchpad-8.jar
  3. This starts the Sling embedded Web Server on port 8080 and writes application files into the sling folder found in the current working directory of your choice. You can check http://localhost:8080/system/console/bundles to see if the application is started properly or not. The credentials would be admin/admin. Here you would see different bundles in started state.
  4. Create content by giving the below cUrl command:
    curl -u admin:admin -F "sling:resourceType=training/aem" -F "title=Sling for AEM" http://localhost:8080/content/myaemnode

            We can expect a response as below:

Screen Shot 2016-07-26 at 6.42.54 PM

Now check the content by using the below URLs from web browser.

Content node in HTML format: http://localhost:8080/content/myaemnode.html

Screen Shot 2016-07-26 at 6.46.47 PM

Same node in JSON format: http://localhost:8080/content/myaemnode.json

Screen Shot 2016-07-26 at 6.45.52 PM


Template:

A Template is used to create a Page and defines which components can be used within the selected scope. A Template is a hierarchy of nodes that has the same structure as the page to be created, but without any actual content. Each Template will present you with a selection of components available for use.

Templates are built up of Components. Components use, and allow access to, Widgets, which are used to author/render content. A Template is the basis of a Page. To create a Page, the Template’s content must be copied (/apps/<application name>/templates/<template name>) to the corresponding position in the site-tree.

CRXDE Lite:

CRXDE Lite is embedded into CQ5/CRX and enables you to perform standard development tasks in a Web browser. With CRXDE Lite, you can create and edit files (e.g. JSP, Java, HTML, etc.), folders, Templates, Components, Dialogs, nodes, properties, and bundles; all while logging and integrating with SVN.

CRXDE Lite is recommended when you do not have direct access to the CQ/CRX server, when you develop an application by extending or modifying the out-of-the-box Components and Java bundles, or when you do not need a dedicated debugger, code completion and syntax highlighting.

Page-rendering Component:

Components are modular, re-usable units that implement specific functionality/logic to render the content of your Web site. They have no hidden configuration files, can include other Components, and can run anywhere within CQ5 or in isolation (e.g. portal).

A Component could be described as a collection of scripts (e.g. JSPs, Java servlets, etc.) that completely realize a specific function. More specific, a “Page” Component is typically referenced by a Template.

Page:

A Page is where content authors will create and edit content that will most likely be published and viewed by site visitors. It is an exact copy of the Template from which it was created.