Beruflich Dokumente
Kultur Dokumente
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 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.
NOTE
CRXDE is an Early Access Technology (EAT) product. Please see DayCare product download
section for details (you are going to need DayCare login to access it).
The screenshot shows CRXDE main window, with content navigator, editor window with a JSP file, outline of
the file, and properties of the content node.
You can now use CRXDE to develop your application.
By default, CRXDE does not need to be configured. For advanced use cases, CRXDE offers advanced
options to:
• Change the CRX server endpoint.
• Change the compiler output path.
• Change the mounted folders.
Creating a Project
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.
Day recommends that you create the following structure for your application:
• /apps/<application-name>: the application container
• /apps/<application-name>/components: the components container
• /apps/<application-name>/templates: the templates container
• /apps/<application-name>/src: the bundles container
• /apps/<application-name>/install: the compiled bundles container
• /apps/<application-name>/docroot: the static files container
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
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 the following structure:
• /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:
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 Commit.
2. Set the User Name, Password and Message. Click OK.
Updating from SVN
1. In CRXDE, in the Navigator tab, right-click the file or the the folder that you want to update, select
Update.
2. Set the User Name and Password. Click OK.
Viewing the SVN Status
1. In CRXDE, in the Navigator tab, right-click the file or the folder under version control, select Status.
2. The SVN status appears in the Console tab.