As we have seen, the high-level workflow for creating a basic cartridge is:
Step 2 is necessary during development in order to have a cartridge instance with which to test. However, once the cartridge is complete, the business user is typically responsible for creating and maintaining cartridge instances in Experience Manager.
In the following sections, we'll describe each of these elements of the cartridge in greater detail.
The template defines the configuration that the business user can specify in Workbench using Experience Manager.
The
template contains these main sections: the
defaultContentItem
element, the
EditorPanel
element, and the
typeInfo
element..
The
content item is a core concept in Assembler applications
that can represent both the configuration model for a cartridge and the
response model that the Assembler returns to the client application. A content
item is a map of properties, or key-value pairs. End users know content items
as
rules. The
defaultContentItem
element in the template contains
properties with default values,
The
EditorPanel
defines the interface that can be used in
Experience Manager to configure the properties of the content item. The
editor panel is composed of a number of
editors. The editors provide the UI controls that the
business user can use to specify the property values for a particular instance
of that cartridge.
The
typeInfo
element defines property type information.
In our example template, we defined two string properties named
message
and
messageColor
and attached two simple string editors to
those properties.
For more information about creating and managing cartridge templates, see About creating templates.
The business user creates and configures instances of cartridges in Experience Manager based on a template. During cartridge development you need to create at least one instance of a cartridge for testing.
Experience Manager writes this cartridge instance configuration as JSON.
The Assembler retrieves this configuration at runtime and uses it to build the response model that it returns to the client application.
For any given cartridge, the default behavior is for the Assembler to do no processing on the configuration and simply return the configuration content item as a map of properties. That is, the response object is the same as the configuration object unless specific processing logic is defined in the Assembler for that cartridge.
As a best practice, the client application should be composed of modular rendering components, each corresponding to a particular cartridge.
Recall the contents of the Assembler response object corresponding to the example cartridge:
"@name": "Hello World", "@type": "HelloWorld", "message": "Hello, World", "messageColor": "#FF0000"
For each cartridge, the
@type
of the response object corresponds to the folder
name of the template that was used to create it. The Discover Electronics
application uses this type to identify the appropriate renderer to use for this
content item.
The logic for mapping response objects to the appropriate renderer is
contained in
include.tag
in the reference application.