Documente Academic
Documente Profesional
Documente Cultură
Adobe Summit
Hands-On Labs
L4205 - Faster time to value with Adobe
Experience Manager Core Components
ii
Table of Contents
Introduction .................................................................................................................................................. 1
Lesson 0 - Core Components ...................................................................................................................... 2
Objectives ............................................................................................................................................. 2
Overview .............................................................................................................................................. 2
Prerequisites and Preparation ............................................................................................................. 4
Lesson 1 - Starting the Project .................................................................................................................... 8
Objectives ............................................................................................................................................. 8
Step 1: Generate an AEM Project ........................................................................................................ 8
Step 2: Import the Generated Project into Eclipse ............................................................................. 8
Step 3: Publish the Generated Projects to Eclipse ............................................................................. 11
Lesson 2 - Create a Simple Template ........................................................................................................ 13
Objectives ........................................................................................................................................... 13
Step 1: Create a new Template ........................................................................................................... 13
Step 2: Add Structural Components to the Page ............................................................................... 15
Step 3: Add a Basic Stylesheet to the Template ................................................................................ 17
Step 4: Set up a Two Column Layout ................................................................................................ 19
Lesson 3 - Adding a Core Component to the Project ............................................................................... 20
Objectives ........................................................................................................................................... 20
Step 1: Creating a Text Component ................................................................................................... 20
Step 2: Doing It Again ........................................................................................................................ 23
Step 3: Allowing ese Components in Our Template ..................................................................... 26
Step 4: Add the Title Component to the Template ........................................................................... 29
Step 5: Enable the Template ............................................................................................................. 30
Lesson 4: Creating a Page with Our Template .......................................................................................... 31
Objectives ........................................................................................................................................... 31
Step 1: Create a Page .......................................................................................................................... 31
Step 2: Add Text to the Page ............................................................................................................. 32
Step 3: Add Images to the Page ........................................................................................................ 33
Lesson 5: Styling the Core Components ................................................................................................... 34
Objectives ........................................................................................................................................... 34
Step 1: Add a TypeKit font kit ............................................................................................................ 34
Step 2: Add a CSS Stylesheet ............................................................................................................ 35
Lesson 6: Conguring the Core Components ........................................................................................... 38
Objectives ........................................................................................................................................... 38
Step 1: Seing a Policy for the Text Component ............................................................................... 38
Step 2: Seing a Policy for the Image Component ........................................................................... 40
Lesson 7: Extending the Core Components .............................................................................................. 42
Objectives ........................................................................................................................................... 42
Step 1: Extending an HTL Script ........................................................................................................ 42
Step 2: Extending a Java Model ........................................................................................................ 44
Wrapping Up - Recommendations ............................................................................................................ 47
Appendix: Using is Workbook Outside of Summit ............................................................................... 48
Soware Installations ......................................................................................................................... 48
Soware Setup ................................................................................................................................... 49
Files .................................................................................................................................................... 50
Introduction
In this lab we will explore the new Adobe Experience Manager Core Components. e Core Components
are a new initiative by the Adobe Experience Manager team to provide a set of resuable and extensible
components which can help projects get up and running in a way that helps to ensure future success.
Overview
Adobe Experience Manager has long included a set of components called the Foundation components
for generic functionality like text blocks, images, lists and so on. For the release of Adobe Experience
Manager 6.3, we have developed a new strategy for supporting these types of common components and
new implementations that we are referring to as the "Core Components". ese Core Components have a
number of key differences from the existing Foundation components.
e initial release of the Core Components contains 12 components, of which we will only be using a
handful in this lab, but the concepts apply to all of them:
• Page
• Title
• Text
• Image
• List
• Breadcrumb
• Sharing
• Forms Container
• Forms Buon
• Forms Text
• Forms Options
• Forms Hidden
e goal of the Core Components initiative is to provide reusable, production-ready components which
accomodate the most common use cases and can then be extended for more specic use cases. ese
components are congurable through the AEM Template Editor and we will be using this capability in
this lab. e HTML produced by the components is all accessible, semantic and mobile-ready. Perhaps
the most fundamental difference between the Core Components and the Foundation components
is that, following the release of AEM 6.3, the Core Components will be available in a public GitHub
repository, hps://github.com/adobe-marketing-cloud/aem-core-wcm-components, and will have
regular ongoing releases which are not directly tied to a new release of Adobe Experience Manager.
One of the concerns customers and partners have raised in the past about the Foundation components
is that when they use them directly, it becomes difficult to manage over time when they "outgrow" the
capabilities of the Foundation components and need to implement their own extended components.
Further, Adobe has had problems updating the Foundation components since we have a large installed
based using those components and need to be extremely careful about backwards compatibility. In
order to handle both of these problem, the Core Components are versioned, which allows us to iterate
on them over time, and their usage by customer requires the use of "Proxy Components". ese proxy
components are what are actually exposed to authors using AEM. We will be exploring the creation of
proxy components in this lab.
In a deployment of AEM, there could be multiple different proxy components for different sites or
business units and each of these proxy components could point to a different versioned of the proxied
Core component.
Note
For obvious reasons, the initial release of the Core Components only has a single version (v1)
for each component.
Now that we’ve done the basic overview, let’s jump into the lab.
Eclipse setup
1. In Eclipse, click on the Servers view.
9. Right click on the entry in the Servers view and select Start.
Status Check
Before proceeding, make sure that
• AEM is running.
• Eclipse is running.
• e Server entry in Eclipse shows a status of Started.
Note
ere is also a product feature called AEM Projects, which we are not using in this lab, which
is used to structure authoring activities. Here we are generating a code project which will
contain the application code running inside AEM.
is will create a new project with the aem-multimodule-project-summit2017 template in a new
folder named my-project. You can actually specify any folder name you want here.
Lazybones will then prompt you with a number of questions about how to set up the project. For this
lab, the defaults are all ne, so just keep pressing the Return key until you see the message
Project created in my-project!
Open the File menu and select Import. In the Import type, select Existing Maven Projects (inside the
Maven folder).
Click the Browse buon and select the my-project folder (if you chose a different folder name when
generating the project, select it instead).
You should now see three new projects added to the Project Explorer view.
• example-project.core - is project contains Java code which will be deployed to AEM as an OSGi
bundle. We will use this in the last lesson.
• my-project - is project acts as the container for the two other projects. We will not be using this
project directly in this lab.
In Eclipse, in the Servers view, right-click on the Adobe Experience Manager on localhost server and
select Add and Remove…
Important
Eclipse will now publish these projects over to the AEM instance. is will take a few seconds to
complete. You can see if it is done by expanding the item in the Servers view. e two projects listed will
be tagged with "Synchronized".
To start, go to the Chrome browser window and log into AEM using the username admin and the
password admin.
From the Start page, click the Tools icon (a hammer) and click on Templates.
In the Create Template wizard, select the My AEM Project Empty Page template type and click the Next
buon.
Tip
A Template Type is a sort of "template for templates". Developers will generally create them
but in this case, the lazybones script generated these two for the lab.
On the Template Details step, provide a title for your template and click the Create buon.
Once your template has been created, click the Open buon to open the template.
To start, mouse over the white area around the box labeled "Drag components here". An orange
bounding box will appear. Once it does, click the mouse buon to show the component toolbar. Click on
the Policy icon, the rst item in the toolbar.
is will open the Layout Container Design dialog. Here we will specify the set of components which are
allowed to be placed into the Layout Containers. For now, we will only specify that Layout Containers
can be added (i.e. we are allowing for Layout Containers to be nested in other Layout Containers).
In the dialog, specify a title for the policy in the Policy Title eld (any value will do, but pick something
intuitive like "My Layout Container Policy"). en open the General category in the right panel and check
the box next to Layout Container. Finally, click the check mark in the top-right corner.
You will now be back in the Template Editor. Drag the Layout Container component from the le panel
onto the box labeled Drag components here. en do this a second time. Once done, the template
should look the image below.
Note
If the Components panel is not displayed on the le side of the screen, you should click on the
Toggle Side Panel icon in the top toolbar to open it.
Finally, we need to unlock the newly added containers so that an author will be able to add components
to them. Click on the rst layout container to expose the toolbar and click on the lock icon.
When you are done, the template should look like the image below.
To start, open the Page Information drop-down menu from the top tool bar (the icon looks like three
sliders) and select Page Design. is will allow us to specify the policy for the page (whereas before we
were specifying it for a particular component).
As when we set up the policy for the Layout Component, provide a title for the policy (again any value
will use but an intuitive value like "My Page Policy" is a good idea).
Click the Add buon under Client-Side Libraries and enter my-aem-project.main in the text eld. Finally,
click the check mark in the top-right corner.
Note
In prior versions of AEM, this was done through a separate mode, called Layouting. While the
Layouting mode still exists, this can now be done directly in the Structure mode.
To start, click on the rst Layout Container component to select it. is will open the component’s
toolbar. Click the Layout buon on the toolbar (the double-headed arrow).
Drag the circular handle on the right side of the screen four columns to the le.
Repeat for the second Layout Container, dragging from the right by eight columns.
When you are done, the template should look like the image below.
To start, switch to Eclipse. In the Project Explorer view, open the example-project.ui.apps project
and open up the folders src/main/content/jcr_root, then apps, then my-aem-project and nally
components.
Right click on the content folder and select New and then Node.
Note
If you get a message box stating that node types cannot be veried, click the Continue (do not
ask again) buon.
In the New Node dialog box, provide text as the node name and cq:Component as the node type. Click
the OK buon.
In the boom pane, switch to the Properties view. Click on the JCR Properties tab. en click on the
newly created text node to display the properties in the Properties view.
Right-click inside the Properties view and select Insert from the context menu. Double-click in the newly
created row and set the Name to componentGroup and the Value to My Project. Repeat this two more
times with the following values.
Name Value
componentGroup My Project
jcr:title Text
sling:resourceSuperType core/wcm/components/text/v1/text
When you are done, the Properties view should look like the screenshot below.
Note
ere are at least two other ways to do this. If you are familiar with AEM and/or the Eclipse
tooling, feel free to use your method of choice.
Name Value
componentGroup My Project
jcr:title Title
sling:resourceSuperType core/wcm/components/title/v1/title
Repeat again to create an image component. Name the node image with the node type of
cq:Component and specify these properties:
Name Value
componentGroup My Project
jcr:title Image
sling:resourceSuperType core/wcm/components/image/v1/image
Because we want to enable a specic drag-and-drop behavior for the image component (specically that
it gets created when an image asset is dragged into the page), we need to do a few extra steps. First, with
the image node selected, right-click in the JCR Properties view and select Show in editor. is will open
the XML representation of this node in the Eclipse editor and Outline view. In the Outline view, right click
on the jcr:root entry and select Edit Namespaces.
In the Edit Schema Information dialog, click the Add buon. Select Specify New Namespace. As the
Prex, enter cq. As the Namespace Name, enter http://www.day.com/jcr/cq/1.0. Click the OK buon.
Back in the Edit Schema Information dialog, click the OK buon. en click the Save icon.
en select the image node and create a new node inside it (right-click, select New, then Node). Enter
cq:editConfig as the node name and cq:EditConfig as the node type.
Caution
ese values are different only by a single casing change. Be careful.
On the desktop of your lab machine, open the le named image-edit-config.txt and copy
the content of this le to your clipboard. In the XML editor in Eclipse, select the line which reads
<cq:editConfig jcr:primaryType="cq:EditConfig"/> and replace it with the contents of the le.
Note
You may need to switch to the Source tab before making this change directly to the XML le’s
content.
When you are done, the le should look like the image below.
1. Allow the use of the Title component in the Root Layout Container so that we can add a Title
component to the top of the template.
2. Allow the use of the Text and Image components into the child Layout Containers so that those
components can be added by an author.
3. Set up the Image component to be the default component created when image assets are added to
pages created from our template.
To start, switch back to the Template Editor. Click on the Root Layout Container and open the Design
Dialog (just like we did in Lesson 2).
Scroll down the list of component groups until My Project is displayed. Click the caret to show the
component list and select the Title component.
Click the check at the top of the page to save the changes to the policy.
Now we need to set up a policy for the two other Layout Container in this template. Start by clicking on
the le Layout Container and click on the Policy icon.
Specify a new name for the policy (for example "Content Layout Container Policy"). en scroll down the
list of component groups until My Project is displayed. Click the caret to show the component list and
select the Text and Image components. Click the check at the top of the page to save the policy.
Repeat this to open the policy a second time. is time, select the Default Components tab on the right
panel. Click the Add mapping buon.
In the Component drop down, select "Image - My Project" (it should be the only option). e default
entry for Mime types should be populated with image/.*.
Click the check at the top of the page to save the policy.
Now click on the right Layout Container and click on the Policy icon.
Click on the Select policy drop down list and select the policy you created above.
Click the check at the top of the page to save the policy.
en click the Enable buon on the toolbar. In the resulting dialog, click the Enable buon.
Select the My AEM Project folder in the rst column. Click the Create buon and select Page.
Specify a title for your page and click the Create buon.
When the page is created, click the Open buon to open it in the page editor.
When the Text component appears in the page, click on it to select it. Click on the Edit icon.
Type some text and then click the check mark in the toolbar to save your changes.
You’re probably noticing that this doesn’t look quite right — the images aren’t sized correctly and are
geing cut off. We’ll x that in the next lesson with a CSS stylesheet.
To start, switch back to Eclipse. In the Project Explorer view, open the example-project.ui.apps
project and open up the folders src/main/content/jcr_root, then apps, then my-aem-project, then
components, then structure and nally page. Double-click on the le customheaderlibs.html. is
le allows us to add more code into the <head> tag of the HTML generated by the template.
Add the contents of the le named typekit.txt on your desktop to the end of this le. en save this
le.
Set the le name to styles.css and click the Finish buon.
e CSS we will use just has two rules. We are rst going to style all text in the core components with the
font in the TypeKit kit (Filson So). en we will specify that all images should take up 100% of the space
available by their containing component.
Open the le named styles.txt on your desktop and copy/paste the contents of this le into the editor
window.
Once adding this content to the CSS le, click the Save buon.
en double-click on the le css.txt in the main folder and add a new line containing styles.css at
the boom, below grid.less. Click the Save buon.
With these two changes, our page should look slightly beer. Go back to the browser. Hold down the
Shi key and click the Reload icon.
Start by switching back to the Template Editor browser tab. In the le Layout Container, click on the
Policy icon for the Text component.
Specify a title for the policy. Click the caret next to the Formaing header in the Properties panel and
click the Show underline option checkbox.
Click the check mark in the top right corner to save the policy.
Switch back to the page editor browser tab and reload. Click on the text component you created before
to open the toolbar and click on the edit icon. Click on the formaing toolbar item (the leer A) and you
will now see an underline option.
Specify a title for the policy. In the right pane, switch to the Feature tab. Click the caret next to the
Cropping header in the Properties panel. Click the Add buon to add a new crop ratio. Set the name to
Cinemascope and the Ratio to 0.4184.
Click the check mark in the top right corner to save the policy.
Switch back to the page editor browser tab and reload. Click on the image component you created
before to open the toolbar and click on the edit icon.
Click on the full screen icon to enter the full screen editor. Click on the crop toolbar item and you will
now see the newly added crop aspect ratio.
e rst extension case we’ll do is to extend the placeholder text shown by the Image component when
it is added to a page but before an asset has been chosen. We actually haven’t seen this placeholder
yet in the lab because we’ve been adding assets directly from the asset nder and having the Image
component automatically created for us. So let’s rst drop in an empty Image component.
To start, make sure you are back at the Page Editor. If you are in the full-screen image edtior, this involves
clicking on the minimize buon in the top right corner and then the X icon to exit the inline image editor.
Switch to the Components panel in the sidebar (if necessary) and then drag the Image component below
the Text component.
is will add an empty Image component to the page with the placeholder text Image.
To change this placeholder text, switch over to Eclipse. Navigate to the image component (which should
be already visible, but if not, open the containing folders to expose it). Right-click on the image folder and
select New:File from the context menu.
Specify image.html as the le name and click the Finish buon.
Put the contents of the le named custom-image-htl.txt from your desktop into this blank le. en
save the le.
e only difference between this le and the image.html le from the base Core component is the
second to last line which sets some text to append to the placeholder.
Note
You probably wouldn’t format that line exactly like this. at is just for readbility in the lab.
Go back to the Page Editor browser tab and reload. You should now see the custom text added to the
placeholder.
To start, go back to Eclipse and open the example-project.core project and then expand the src/
main/java folder. Right click on the com.myco.models package and select New:Class from the context
menu.
Put the contents of the le named custom-title-class.txt from your desktop into this le, replacing
any content. en save the le. As with the HTL example above, this class is only different from the
standard class by a single line — line 55 which returns the static string "My Project - " before the title.
Finally, go back to the browser and reload the Page Editor. You should see the Title component updated
to use the new model.
Wrapping Up - Recommendations
Now that you’ve seen a bit of what the Core Components can do, you may be interested in starting to
use them. Before jumping in with both feet, it is worth considering Adobe’s recommendation on when
and how to use these components.
For new projects starting on AEM 6.3, we recommend starting with the Core Components where
possible. ere are some Foundation components which do not (yet) have counterparts in the
Core Component set and if those are suitable for your project, by all means use them. But we don’t
recommend using both, for example, the Core Title component and the Foundation Title component in
the same template, largely because that would be confusing to authors.
For existing projects upgrading from a prior version to AEM 6.3, unless there is a larger project requiring
refactoring, there is no need to move from the Foundation Components. Eventually we will deprecate
the Foundation Components, but we have to reach feature parity rst. With respect to your custom
components, while those aren’t impacted by these new Core Components, it is worth looking at the
paerns used by the Core Components and adopting them for your custom components.
Soware Installations
AEM
is workbook requires the use of AEM 6.3. You can use any release following Beta Load 4 (internal
designation for Beta Load 4 is Load 19). A valid Adobe Experience Manager license is required.
Eclipse
For the purpose of this lab, we are using Eclipse Neon.2, the current release. To install it, please follow
these steps:
Lazybones
Lazybones is installed using a two-step process. First, install sdkman, a Soware Development Kit
management system. Instructions for installing sdkman can be found at hp://sdkman.io/install.html. In
short, in a Terminal window, run these two commands:
curl -s "https://get.sdkman.io" | bash
source ~/.sdkman/bin/sdkman-init.sh
Note
Windows users can nd a PowerShell version of sdkman at hps://github.com/ofreud/posh-
gvm. It might also be easier to download the Lazybones distribution, unzip it, and add it to
your path. See hps://github.com/pledbrook/lazybones#running-it
Maven
Maven can be installed using Lazybones as well:
sdk install maven
Soware Setup
Lazybones
e Lazybones template used in this workbook is not available in a standard Lazybones conguration. To
enable it, you must rst create a directory named .lazybones in your home directory. In this directory,
create a le named config.groovy and populate it with:
bintrayRepositories = [
"acs/lazybones",
"pledbrook/lazybones-templates"
]
Maven
If you are using this workbook before AEM 6.3 is released, i.e. you are in the AEM Beta program, you must
add the AEM 6.3 UberJar to your local Maven repository. Once you download the AEM 6.3 UberJar (e.g.
from the beta website), you need to install it with this command:
If you are using this workbook aer AEM 6.3 is released, aer you generate the project in Step 1, edit the
le pom.xml and replace:
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<version>6.3.0-summit</version>
<scope>provided</scope>
<classifier>apis</classifier>
</dependency>
with
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<version>6.3.0</version>
<scope>provided</scope>
<classifier>apis</classifier>
</dependency>
Files
e les referenced in this workbook can all be found at hps://adobe.ly/2lRD8lC