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

Getting Started with CRXDE

To get started with CRXDE, proceed as follows:

  1. Install CQ or CRX.
  2. Download the CRXDE package.
  3. Extract the package.
  4. Double-click the executable.
  5. Enter the location of your CQ or CRX installation. By default it is:
    • http://localhost:4502/ for CQ5 Quickstart
    • http://localhost:7402/ for CRX Quickstart
  6. Enter your username and password. By default it is admin and admin.
  7. Click OK.

The CRXDE User Interface looks as follows:

/content/docs/en/crx/current/developing/development_tools/developing_with_crxde/jcr:content/par/image_0/file

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:

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

Importing Files and Folders into the Repository

To import a file or a folder from your file system into the repository with CRXDE:

  1. In your file explorer copy the file (or the folder).
  2. In CRXDE, navigate to the location that will contain the file (or the folder). Right-click and select Paste.

The files are mapped to nodes of type nt:file and the folders to nodes of type nt:folder.

You can also drag and drop the file (or the folder) directly into CRXDE.

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 New, then 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:

     
Property Value Description
Export-Package: * The Export-Package header defines exported packages for the bundle (comma-separated list of packages)
Import-Package: * The Import-Package header defines imported packages for the bundle (comma-separated list of packages)
Private-Package: * The Private-Package header defines private packages for the bundle (comma-separated list of packages)
Bundle-Name: Test Bundle Defines a short, human-readable name for the bundle
Bundle-Description: This is my Test Bundle Defines a short, human-readable description for the bundle
Bundle-SymbolicName: com.mycompany.test.TestBundle Specifies a unique, non-localizable name for the bundle
Bundle-Version: 1.0.0-SNAPSHOT Specifies the version of the bundle
Bundle-Activator: com.mycompany.test.Activator Specifies the name of the optional listener class to be notified of bundle start and stop events

For more information on the bnd format, refer to the bnd utility used by CRXDE to create OSGI bundles.

Creating a Java Class

To create the HelloWorld Java class within the Test Bundle:

  1. In CRXDE, in the Navigator tab, navigate to /apps/myapp/src/com.mycompany.test.TestBundle/src/main/java. Right-click it, select New, then Class.
  2. Set HelloWorld as Name. Click Finish.
    The HelloWorld.java file is created beside Activator.java and displays following code in the main pane:
    package com.mycompany.test;

    public class HelloWorld {

    }
  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:

  1. Stop the CRX server.
  2. Start the CRX server in debug mode: on the command line, change to the directory <crx-quickstart> and enter the following command:
    java -debug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=30303 -jar <quickstart-name>.jar
    Note: you can also enter the following command: server/start -d
  3. In CRXDE, in the top menu bar, select Debug, then Attach Debugger.
  4. As port number, enter 30303 (as defined as the address argument of the Xrunjdwp option). Click OK.
  5. The Debug Perspective is displayed. You can now set breakpoints in the .jsp and .java files.

To switch back to the standard perspective, use cmd + F8 or terminate the debug session by using the Disconnect button in the Debug view.

Integrating with SVN

With CRXDE you can perform the following operations through the tree context menu:

  • Checkout from SVN
  • Update from SVN
  • Commit to SVN
  • View the SVN status

Importing the CRX repository into the SVN server

To import the CRX repository (or part of it) into the SVN server:

  1. Check out the CRX repository (or part of it) into your file system by using the FileVault checkout command. Enter following command in the directory <path/to/crx-repo> that will contain the checkout:
    vlt --credentials admin:admin co --force http://localhost:4502/crx
  2. Import the CRX repository (or part of it) from your file system into the SVN server. Enter following command on the command line:
    svn import <path/to/crx-repo> <URL of the SVN repo>

Checking out from SVN

  1. In CRXDE, in the Navigator tab, right-click the folder that will contain the checkout and select Checkout.
  2. Set the URL, User Name, Password and Path. Click OK.

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.



Your comments are welcome!
Did you notice a way we could improve the documentation on this page? Is something unclear or insufficiently explained? Please leave your comments below and we will make the appropriate changes. Comments that have been addressed, by improving the documentation accordingly, will then be removed.
(optional)
2 comments
Does CRXDE support Conflict Resolving against the Subversion-Repository?
0 Replies » Reply
Where Did my comment go?
0 Replies » Reply
In order to post a comment, you need to sign-in.
 

Forgotten your password? Reset the password here.

Note: Customers with DayCare user accounts need to create a new account for use on day.com.

***

Copyright © 1993-2010 Day Management AG. All rights reserved.