Developing With Crxde
Developing With Crxde
Developing With Crxde
This section describes how to develop your JCR, Apache Sling or CQ5 application with CRXDE.
Please refer to the overview documentation for more information on the different development environments
that are available.
CRXDE is a pre-packaged stand-alone Eclipse application. CRXDE is custom-built specifically for CQ and
CRX and thus enables you to efficiently develop your project. CRXDE gives you a broad set of tools to easily
create a project, create and manage files, folders, templates, components, dialogs, nodes, properties, scripts
and bundles while logging, debugging and integrating with SVN. CRXDE is built on the Eclipse Rich Client
Platform (RCP), leveraging the Eclipse File System (EFS) API.
CRXDE is recommended when you develop complex applications by creating new components and Java
bundles.
1. Install CQ or CRX.
2. Download CRXDE:
• In case CRX Launchpad web application is installed under another context (e.g., /launchpad instead of
/), you need to login to this URL
• http://<host>:<port>/launchpad
• In case CRX web application is installed under another context (e.g., /daycrx instead of /crx), you need
to configure the CRX server endpoint to use this context (/daycrx/server)
Supported Products
CRXDE supports the following Day products:
• CRX repository
• CQ5 suite of content management products; CQ5 is based on CRX repository
CRXDE release by default supports at least the latest version of CRX, and the CQ5 product which is based
on that repository version. Please see CRXDE compatibility for information about compatibility of CRXDE
with earlier product releases.
CRXDE Features
CRXDE seamlessly offers on-the-fly mapping of a JCR 2.0 repository made of nodes and properties to an
Eclipse representation as files and folders, and "nodes" and their metadata. The underlying technology is
based on FileVault, DavEx remoting and the Eclipse framework.
CRXDE provides the Integrated Development Environment functionalities and features offerred by its
underlying Eclipse platform. These include editing of source code, code completion and restructuring,
searching and browsing, and many others.
Additionally, CRXDE provides extended support for CRX and CQ5 specific development tasks. This
functionality is described in the following subsections.
CREATING A PROJECT
With CRXDE you can create a working project in three clicks. The project wizard creates a new project under
/apps, some content under /content and a package wrapping all the project the content under /etc/packages.
The project can be used right away to render a sample page displaying Hello World, based on a jsp script
that renders a property from the repository and calls a Java class to render some text.
To create a project with CRXDE:
1. In CRXDE, in the Navigator tab, right-click a folder, select Build, then Create Project ....
Note: you can right-click any folder in the tree navigation, as the new project nodes are, by design,
created below /apps, /content and /etc/packages.
2. Define:
• Project Name - the project name is used to create the new nodes and the bundle, e.g. myproject.
• Java Package - the Java package name prefix, e.g. com.mycompany.
3. Click OK.
To access the sample page displaying Hello World, point your browser to:
http://localhost:4502/content/<project-name>.html
The Hello World page is based on a content node, that calls a jsp script through the sling:resourceType
property. The script reads the jcr:title property from the repository and gets the body content by calling a
method of the SampleUtil class, that is available in the project bundle.
CREATING A FOLDER
To create a folder with CRXDE:
1. In CRXDE, in the Navigator tab, right-click the folder under which you want to create the new folder,
select New, then Folder.
2. Enter the Folder name and click Finish.
CREATING A TEMPLATE
To create a template with CRXDE:
1. In CRXDE, in the Navigator tab, right-click the folder where you want to create the template, select
New, then Template.
2. Enter the Label, Title, Description, Resource Type and Ranking of the template. Click Finish.
It creates:
• A node of type cq:Template with Template properties
• A child node of type cq:PageContent with Page Content properties
You can drag and drop a thumbnail from your file system into the template folder.
You can add properties to your template: refer to the Creating a Property section.
CREATING A COMPONENT
To create a component with CRXDE:
1. In CRXDE, in the Navigator tab, right-click the folder where you want to create the component, select
New, then Component.
2. Enter the Label, Title, Description, Super Resource Type and Group of the component. Click Next.
3. If needed, set values for the optional properties Allowed Parents, Allowed Children and check the box
Is Container. Click Finish.
It creates:
• A node of type cq:Component
• Component Properties
• A component .jsp script
CREATING A DIALOG
To create a dialog with CRXDE:
1. In CRXDE, in the Navigator tab, right-click the component where you want to create the dialog, select
New, then Dialog.
2. Enter the Name and the Title. Click Finish.
It creates a dialog with the following structure:
dialog[cq:Dialog]/items[cq:TabPanel]/items[cq:WidgetCollection]/tab1[cq:Panel]
You can now adapt the dialog to your needs by modifying properties or creating new nodes.
CREATING A NODE
To create a node with CRXDE:
1. In CRXDE, in the Navigator tab, right-click the node where you want to contain the new node, select
New, then Node.
2. Enter the Name and the Type. Click Finish.
You can now adapt the node to your needs by modifying properties or creating new nodes.
CREATING A PROPERTY
To create a property with CRXDE:
1. In CRXDE, in the Navigator tab, right-click the node where you want to add the new property, select
New, then Property.
2. Enter the Name, the Type and the Value. Click Finish.
You can also edit properties and add new ones in the Properties tab.
CREATING A SCRIPT
To create a new script:
1. In CRXDE, in the Navigator tab, right-click the component where you want to create the script, select
New, then JSP.
2. Enter the File name. Click Next.
3. Select the JSP Template and click Finish.
The new file opens in the main tab.
You can use the following key combinations for code completion:
• Ctrl + Space on Windows
• Cmd + Space on Mac
To create a Java class, select a folder where you want to place the new class. Usually, it is a part of an
existing Java package (e.g., com/example/mypackage). Right-click the folder, select New, then Class. Fill
out the Eclipse dialog providing information about your class, and click Finish. Your class is created, and its
skeleton source file displayed in the editor.
Once you add source code to your class, you can easily compile it. Right-click the class source file in
Navigator, select Build, then Compile. Your class will be compiled and automatically deployed into CRX
OSGi container. In case of compilation problems, you will see the status in the Remote Build view.
MANAGING A BUNDLE
With CRXDE, it is straigthforward to create an OSGI bundle, add Javaclasses to it, and build it. The bundle is
then automatically installed and started in the OSGI container.
This section describes how to create a Test bundle with a HelloWorld Java class that displays Hello World!
in your browser when the resource is requested.
Creating a Bundle
To create the Test Bundle with CRXDE:
1. In CRXDE create myapp project with the project wizard. Among others the following nodes are created:
• /apps/myapp/src
• /apps/myapp/install
2. Right-click the folder /apps/myapp/src that will contain the Test bundle, select Build, then Create
Bundle ....
3. Enter the following values for the bundle properties:
• Symbolic Bundle Name: com.mycompany.test.TestBundle
• Bundle Name: Test Bundle
• Bundle Description: This is my Test Bundle
• Package: com.mycompany.test
Click Finish.
The wizard creates the following elements:
• The node com.mycompany.test.TestBundle of type nt:folder. It is the bundle container node.
• The file com.mycompany.test.TestBundle.bnd. It acts as deployment descriptor for your bundle and
consists of a set of headers.
• The folder structures:
• src/main/java/com/mycompany/test. It will contain the packages and the Java classes.
• src/main/resources. It will contain the resources used within the bundle.
• The Activator.java file. It is the optional listener class to be notified of bundle start and stop events.
The following table lists all the properties of the .bnd file, their values and descriptions:
For more information on the bnd format, refer to the bnd utility used by CRXDE to create OSGI bundles.
3. Add the following lines into the body of the HelloWorld class:
public String getString(){
return "Hello World!";
}
Save the changes.
Building a Bundle
To build the Test Bundle:
1. In CRXDE, in the Navigator tab, right-click the .bnd file and select Build Bundle.
The Build Bundle wizard:
• Compiles the Java classes.
• Creates the .jar file containing the compiled Java classes and the resources and places it into the
myapp/install folder.
• Installs and starts the bundle in the OSGI container.
To see the effect of the Test Bundle, create a component that uses the Java method HelloWorld.getString()
and a resource that is rendered by this component:
1. Create the component mycomp under myapp/components.
2. Edit mycomp.jsp and replace the code with the following lines:
<%@ page import="com.mycompany.test.HelloWorld"%><%
%><%@ include file="/libs/foundation/global.jsp"%><%
%><% HelloWorld hello = new HelloWorld();%><%
%>
<html>
<body>
<b><%= hello.getString() %></b><br>
</body>
</html>
3. Save the changes.
4. Create the resource test_node of type nt:unstructured under /content.
5. For test_node, create the following property: Name = sling:resourceType, Type = String, Value = myapp/
components/mycomp.
6. In your browser, request test_node: http://<hostname>:<port>/content/test_node.html.
7. A page is displayed with Hello World! in bold.
LOGGING
In CRXDE you can display the file error.log that is located on the file system at <crx-install-dir>/crx-
quickstart/server/logs and filter it with the appropriate log level. Proceed as follows:
1. In CRXDE, in the Console tab at the bottom of the window, click the arrow beside the Display Selected
Console icon and select CQ.
2. In the drop-down menu, set the log level. It can be one of the following values: trace, debug, info, warn
or error.
The error.log is filtered according to the log level and displayed in the tab.
DEBUGGING
To debug with CRXDE:
To switch back to the standard perspective, use cmd + F8 or terminate the debug session by using the
Disconnect button in the Debug view.
TROUBLESHOOTING CRXDE
CRXDE stopped working
Remove the .crxde folder from your home folder.
Note: on Windows the .crxde folder is under c:\documents and settings\<YOUR_USER_NAME>.
The integration is based on many-to-one mapping between JCR nodes and FileVault representation
thereof. This intermediate representation, based on files and folders, is then synchronized one-to-one with
Subversion. SVN status is shown for individual repository nodes, and is mapped from "real" SVN status on
FileVault files (for example, .content.xml representing potentially many nodes).
Conflict resolution
There is very limited support for SVN conflict resolution, so it is recommended to do frequent updates and
short update-commit cycles.
Where more explicit control over SVN operations or full support for distributed development in larger teams is
required, the integration based on stand-alone FileVault vlt client and Subversion client can be used (such as
this project setup based on FileVault, Eclipse, Subversion, and Maven).
1. In CRXDE, in the Navigator tab, right-click the folder that you want to import into SVN, select Version
Control, and then Import.
2. Enter the URL, User Name, Password, Path, and optionally a Message. Click OK. The files are
imported into SVN.
1. In CRXDE, in the Navigator tab, right-click the folder that you want to contain the checkout in, and
select Version Control, then Checkout.
2. Enter the URL, User Name, Password, and Path. Click OK. The files are checked out from SVN into
the desired location.
1. In CRXDE, in the Navigator tab, right-click the folder that you want to export, select Version Control
and then Export.
2. Enter the URL, User Name, Password, and Path. Click OK. The files are exported from SVN into the
desired location without version control.
Committing to SVN
When you create or modify a file or a folder that is under version control, it is automatically added to the
version control.
To commit a change:
1. In CRXDE, in the Navigator tab, right-click the folder that you want to commit, select Version Control,
and then Commit.
1. In CRXDE, in the Navigator tab, right-click the file or the the folder that you want to update, select
Version Control and then Update.
2. If not already logged in, you are prompted for a user name and password. Click OK. CRXDE updates
the file or folder.
1. In CRXDE, in the Navigator tab, right-click the file or the folder under version control, select Version
Control and then Status.
2. View the SVN status in the Console tab.
CRXDE Compatibility
CRXDE 1.0 supports the following product versions.
CRX 2.1
CRXDE supports this version out of the box.
CQ 5.3
CQ 5.3 is based on the CRX 2.0 release (only released as a part of CQ 5.3). To ensure compatibility of
CRXDE 1.0 with CQ 5.3, the CRXDE Support module from CRX 2.1 release should be installed into CQ 5.3.
To use CRXDE with this release, you have two options outlined in the following subsections.
Download from Package Share (recommended). The CRXDE Support package is available on Day
Package Share, in the section Public » Day » CQ 5.3.0 » upgrade. The package is called cq53-update-
crxdesupport. To install it:
Extract the updated components from CRX 2.1 quickstart jar file. If you don't have access to the
Package Share from your instance, you can also get all the required components from a CRX 2.1 quickstart
jar file. Please follow these steps:
• Extract the CRX support package from the CRX 2.1 quickstart jar file:
• unpack the CRX 2.1 quickstart file in an empty folder:
java -jar crx-2.1.0.20100426-<edition>.jar -unpack
• in the folder where you unpacked CRX 2.1, unzip the initial content file:
crx-quickstart/repository/install/crx-initial-content-2.1.0.zip
• using the CRX Package Manager upload and install the CRX 2.1 crxde-support package from the
unpacked zip file:
jcr_root/etc/packages/day/crx210/product/crxde-support.zip
• Then install additional packages:
• navigate to the extracted crx-initial-content-2.1.0
• navigate to jcr_root/libs/sling/install
• upload the following jars to /libs/sling/install (e.g. using WebDAV):
• org.apache.sling.commons.auth-0.9.0-R925144.jar
• crx-auth-token-2.1.0.jar
After upgrading the CRXDE Support package, restart the instance. Start CRXDE and connect to the instance
to check, whether the tool works correctly. Pay special attention to checking, if you can execute server-side
functionalities (like bundle compilation, product creation, CRXDE operations).
After you have successfully installed the upgrade and tested your instance, your CQ 5.3 is ready for
developing with CRXDE.
After you have successfully upgraded and tested your instance, your CQ 5.3 is ready for developing with
CRXDE.