Professional Documents
Culture Documents
Technical Training
Exercise Guide
CQ 5.9 l1eveloper fraillillg
Pu blished September 20 10
Copyright © 2010 Day Management AG, Swi tzerl and. All rights reserved.
No part of th is publication (hardcopy or electronic form) may be reproduced or transmitted, in any form or by any means, electronic,
mechanical, photocopying, recording, or otherwise, without the prior wr itten consent of the publisher. Information in this manual is
furnished under license by Day Software, Inc. and may only be used in accordance with the terms of the software license.
Day, the Day logo, Commun iqu~ and CRX are registered trademarks and service marks, or are trademarks and service marks of Day
Management AG, Switzerland , in various countries around the world. AU other product names and company logos mentioned in the
informatioo, documents or other items provided or available herein may be the trademarks of their respective owners.
We grant you limited license to use materials solely for eduction purposes, You acknowledge that all right.
title and interest (i ncluding IP rights) in and to the materials remains in Day.
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.dav.CQm
• Day 1 6
Day 2 40
Copyright 2010. Day Software AG, Switzerland Rev 1.5 20100907 wwwdav.com
• EXERCISE - Create an Image-based Navigation Component 83
Day 3 96
Day 4 157
EXERCISE - Create and Consume an OSGi Bundle 157
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 wwwday.cpm
•
Day 1
EXERCISE - Install & Start an Author Instance
Goal
The fo llowing instructions explain how to install and start an Author instance.
T his is important because you will use t hi s Auth or instance throug hout th is
training to perform typical development tasks. To successfully complete and
understand th ese instructions, you will need:
1. Create a folder structure on your file system where you will store, install, and
start CQ5 (e.g. C / day/ cq5 / author).
WARNING
MS Windows users, please do not use spaces in your newly created folder structure (e.g . C: / this
is bad / cq5 / author). This will cause CQS to error.
2 . Copy the CQ5 quick start JAR and license.properties fi le from < USB> /
distri bu tion / cq5_wcm into the newly created folder structure.
• cq = t he ap plication
• author == t he WCM mod e it will run in (e.g. author or publish)
• 4502 = the port it will run in (e. g. any available port is acceptable)
NOTE
If no port number is provided in t he f il e name, CQS will se lect t he first avai lable port from the
fo ll owing li st: 1) 4502, 2) 8080, 3) 808 1, 4) 8082, 5) 8083, 6) 8084 , 7) 8085, 8) 8888, 9) 9362,
10) rand o m.
• CQ5
, """
Pas.:: rd •••• -1
Co"gratulatio"s! You have s uccessfu lly installed and started CQ5 . To start CQ5 in
the future , double-click t he renamed CQ5 quic kstart JAR fi le (e.g . cq-
author-4502 .jar).
NOTE
You can also insta ll / start CQ5 from the com mand line whi le increasing th e Java heap size,
w hich wi ll improve performance. Please see image below.
Goal
The followin g instructions explain how to browse the application / server
interfaces associated wi t h a CQ5 installation . T his will enable you to use their
ad mi nistrati ve / con figu ration capa bili ti es. To success f ully complete an d
understand these instructions, you will need :
1. Enter the URL http: // localhost:4502 / admin in your favori t e Web browser' s
add ress bar.
2 . Enter t he default ad ministrator "User name" (ad min) and "Passwo rd " (ad m in)
in the dialog - t hen select OK.
http;lIlocaho~:<tS02/aOOw;
A usemame and password are belOQ reqJested by http://locah;:&: ofS02. The sle says: "D<Iy
~r'kt Engine AdlnlntstTatlOO-
Password : •••••1
,_ _
01
1
-,,_1 , ,:""~ 1
Copyright 2010, Day Software AG , Switzerland Rev 1.5 20100907 wWW:da Y-com
•
...
'B " .."R¥' .....,·P? --""'-.J - J I
--""'-.J ~ • I
~ ---""-.J • I
~ -.
,-----"
-
Co~gratuJ atio~s! You have successfully logged into th e CQSE Java servlet engine.
Typi cally, task s avail able t hrough this interface will be handled by the system
administrator.
1. Enter the URL http:// localhost:4S02 / crx in your favorit e Web browser' s
address bar - t hen sel ect Log In after the CRX interface appears.
cr :~ . .j€ f.;ult v
3. Select Co"te"t Explorer in the Main Console - a new Web browser window will
pop-up .
4. Navigate to the fol der /co ntent/ geometrixx/ en/ company to view a portion of
the Geometrixx Web site structure.
t.1
.J •• -. ,-
-
CQ;P.aQe
I
-
.J ""
.J "'
..J CCW"ll:ef'lI
.J _
.J ....
to
lO:o;r e"'~
ltI:(te.!led3y
",:(ONet'!(
.J _ oave...eo ..
.J 00d
"''''
C<l' P~
cq:P...,..
CQ: P/IO)'!'
j
,J
,J
...J ~'u
to 10'
.J ~
«'f'(ffl.
t. 10 ' _«"-
f
r'
-" - I
_~H
•I
1. Enter the URL http ://localhost:4502 / system / console in your favorite Web
browser' s address bar.
2. En ter t he defa ult ad ministrator "User name" (admin) and "Password" (admin)
in the d ialog - t he n se lect OK.
hUp:fllocahost:'1502/systemjeonsoie
~--.--
A~lh •.ntiF~!i2L>~R!>.g~lr.d -----.._ -
~
A U$efnatne and pass'HOId ore being requested by httP:/~ocalhost: 4 502. The site says: MOSGi
Man3Qement C~~
password: •••••1
"" I, c.",~
3. Select ~ece"treq u ests - then select Clear to remove recent requests from the
dis played list .
Copyright 2010. Oay Software AG, Switzerland Rev 1.5 20100907 Www dav.com
• A.. _ 1'1'
!F"k •• ,,,,,,,,, ..
It i,
I .. ~
I
U .. ,'1"
"'
.h
(h'"r I_
(",FT t.l"'H-On.nfl - F" _, , r '\t
·F " .' I',
'.~.r t·_,., I .;!!.,~ .... ..._~- bQ: .1- 'n
.' '"'
,t.
Co"gratulatio"s! You have successfully logged into the Fe lix application and have
removed recen t requ es ts from t he d isplayed list. You can use this request
information to investigate the internal workings of CQ5.
Goal
The following instructions explain how create an application / project in CQ5
using CRXDE Lite. This will provide an area for you to build CQ5 elements
(Templates, Component, etc.) To successfully com plete and understand these
instructions, you will need :
1. Enter the URL http : // localhost:4502 / crxde in your favorite Web browser's
address bar.
~Iame : admin
Pas5v\"ord: ·····1
Workspace : cr)(.default
:an.::el
=l .. I
.±l ~ tep:policy .;
zl iii jer :systern <:
zl ......:sr
~ .Jr.bs
!:l etc
=l apps
.::l geometrixx
..:J... components ,J1,..
..±J 0.# aS5etedit or ·u
.±I .,J assetshare
~ .I blog
, .. ..... .
Copyright 20 10, Day Software AG, Switzerland Rev 1.5 20100907 www.day.com
•
CO"Qratulatio"s! You have successfu lly logged into CRXDE Lite and have browsed
the custom compo nents created for the Geometrixx Web site/ project. Again,
CRXDE Lite is embedded into CQS / CRX and enables you to perform standard
development t asks in a Web browser.
What is an application/project?
An appl ication / project is where you will sto re CQS elements suc h as Templates,
Com po nents , OSGi bundl es, and static files. In order to start a new application /
project, it is neces sary to def ine a location f or t hese elements . Typically, they
are defined as a subfolder of th e / apps fol der. Day recommends that you create
the following st ructure for your application / proj ect :
Structure Description
l apps! < application name > The application container
l apps l < application name > I The Components container
components
I
l apps l < application name > I The MPage n Components container
components / page
I apps l < application name > I The ~Co nt ent" Components container
components / content
l apps / <application name > / templates The Templates contai ner
/ apps /< application name >/ src The aSCi bundles container
l apps l < application name > / install The compiled aSCi bundles container
lap ps ! < appl ication name >/ global T he static and other global files container
1. Rig ht - c lick the folder un d er w h ich you want to create the new fo lder - then
select Create .... Create Folder ...
3~ 1
.tI ~ rep:poItcy
.11 ... )Cr:system
'>
2. Enter the fo ld er "N ame" (training) you wish to create in the d ia log - then
select OK.
Create r older
r«ne:
I"
CRXDE Lite create folder dialog
oj:!. I
.. :!. ,..,,,ohcy
.!t ,f, }Crsyrtem
.!:I \J var
.. cJ It"
.!:I t) e-.c
.;;I U aPll5
'" cJ found"tion
j;j 4J qeomctnlOC
.::::J Jtr.un ng
.;;I \J components
1:1 ....J conte"!:
.. ..J ....,
j;j..) global
.:tI \.J Irtsta 1
1:1 U 'ire
:=I ~ teMp ales
.:tI LJ conten:
.!:I t.J tm:l
.. 1..---
CRXDE Lite completed appl ication structure
Save All · Cr ec
tJ
....
CRXDE Lite save all
Co"grat ulatio"s! You have successfu ll y created an application / project and related
structure in CQ5. It is not uncommon to add additional structure to the
components folder, as t here can be many types of custom Com ponents (e.g.
nav, header, footer, etc.).
Copyright 2010, Day SoftwareAG, Switzerland Rev 1.5 20100907 WWW.da Y. com
•
EXERCISE - Create a Template
Goal
The followin g instructions explain how to create a Template using CRXDE Lite.
By creating a custom Template, you wi ll be able to create Pages based off of
that Te mplate, enforcing a consistent loo k and feel. To successfu lly complete
and understand t he se instructions , you will need:
What is a Template?
A Temp late is used to create a Page and defines which components can be used
within t he selecte d scope. A Temp late is a hierarchy of nodes that has the same
structure as the page to be created , bu t w ithout any actual content. Each
Templ ate wi ll present you w ith a selection of components avai lable for use.
Templates are built up of Co m ponents . Co m ponents use, and allow access to,
Widgets, wh ich are used to au t hor/ rend er content.
This copy action also gives the Page its initial content and the property
sl ing :resourceType , the path to the "Page" Component that is used to render
the page .
1. Rig ht- click / apps/<a pplication namo/ templates - t hen select Cr••te...• Create
re..plate ...
2 . Enter the des ired Template "Label", "Ti tle", "Description", "Resource Type",
and "Ranking" in t he d ialog - t hen select Next.
Copyright 2010, Day SoftwareAG , Switzerland Rev 1.5 20100907 www.da v . CQm
• • Label = t he name of the Template / nod e t hat will be created
• content pag e
• Titl e (property j cr :title) =- th e titl e t hat wil l be assi g ned to the Temp late
• Training Contentpag e
• Description (property jcr:des cription) = the description that will be assigned to
the Tem plate
• NA
• Resource Type (property sling:resourceType) = the Component's path t hat wil l
be assigned to the Template and copied to implementing pages
• training /components / page / contentpage
NOTE
The property sling:resourceType wil l be created on the Template's jcr:content node. In
addition , the Compone nt may not yet exist. Th is is because you have not yet created it .
• Ran k ing (property ranking) = th e ord er (ascend ing) in wh ich th is Temp late will
appear in relation to other Templates. Setting the Rank to ' . will ensure that our
Te mp late appears first in t he list.
• 1
(reate Template x
label: contentpage
Description: N.c".
Ccrn:el
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.claIGCQID
•
3. Select Next for "Allowed Paths". Allowed Paths will define paths where this
template may be used to create pages.
[reate Template
Allowed Paths
+
"
, ..... ........... '-~ .
t ....' . ..' oJ' .
",...
,...,.
CRXDE Lile creale template allowed palhs
4. You will need to add an Allowed Path. Click on the plus sign and enter the
foll owing value : leonlenl(/' *)7
NOTE
If you forget to enter aliowedPaths before clicking on Fini sh. Create the following
property on your te m plate node :
Create Template f
il.llow ed Children
+
...•
• ~ ' '''' ' _ .• ,. ',.'. . ~ ..
l" - , " . "
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www·da v.com
•
NOTE
Don 't forget to click Save All to persist your changes in the repository.
Co"gratulatio"s! You have succes sfu lly created a Te mplate in CQS. To make you
more aware of the structure associated with CQS objects, it is a good idea to
view the nodes and propert ies t hat were created in the repository (CRX). Please
see the image below.
=J tJl
±I rep :policy
±I jJ )Cr. system
.±J ~ var
±I LJ I,bs
±I ..J etc
=1 .) ao:>s
±I V foundation
j:J ~ georne--lIixx
=l ...J train ng
±I t.J components
±I ;..J g lobal
±I tJ insta I
±I LJ ;cc
=J L.l teMP ales
.::tI cor.tcmpage
.±l \..J content
+1 11 '1 tm n
Goal
The following instructions explain how to create a "Page" Component us ing
CRXDE Lite. The Template you created in a previous exe rci se wi ll use this
Component's resources (scripts, d ialogs, etc.) to aid in rende ring Pages based
off of that Te mplate . To successfully complete an d understand the se
instructions, you will need :
2. Enter t he desired Component "Labe l", "Title", and "Description" in the dialog-
then select Next.
• NA
World Standard Software to Unify Your Business 23
Copyright 2010, Day SoftwareAG , Switzerland Rev 1.5 20100907 www.dav. com
•Create Component x
Label: contentpage
Descnptlon: NA
Super Type :
Group:
Ne ·t ~ ":aned
Creat e Componenl
,
Advanced Component Settings
Is Container : .,
fo,J o Decor atian : c "
.'
Cell ~Jame:
Dialog Path :
~
..-
.... ... . .- .... ..... ...... ... .. . ,./ "-"'-' .
- - ,, ~ ..
.r
CRXDE Lite create component advanced settings
World Standard SOftware to Unify Your Business 24
4 . Open t he script by dou ble-clicking the script o bject in the left pane . The
script contains some sample code that may have to be adjusted or deleted,
depending on what the com ponent wil l do.
S. Enter some HTML code , similar to be low - then select Save All.
NOTE
Don 't forget to dick Save All to persist your changes in the re pository .
Copyright 2010, Day SoftwareAG , Switzerland Rev 1.5 20100907 www.day. cQro
•
EXERCISE - Create Pages & Web Site Structure
Goal
T he fo llowi ng instructions explain how to create Pages and Web site structure
in CQS. These Pages are what / w here author's will manage content. To
successfully com plete and understand these instructions , you will need :
What is a Page?
A Page is w here content authors will create and edit content that will most likely
be pu bl is hed and viewed by site visitors. It is an exact copy of the Temp late
from which it was created.
1. Select "Websites" in the CQS Siteadmin tool - then select New .. " New Page ...
Copyright 2010 , Day Software AG, Switzerland Rev 1.5 20100907 wwwclay.com
•
2. Enter a nd se lect the desired Page "Title", "Name" and Template on wh ich to
base this Page on - t hen click Create.
• Title (p ro perty jcr:title) = the title that will be assigned to the Page
• Name ::: the nam e of the Page / node that will be created
Create Page x
tra ,n ngSite
Form Templ.te
A.!kMS ~ ere.]:",: CL'Sb'n pJ.m fc!nns for ed:f!f19 resoom5.
CII~"dar
Ctm:f' a -:a!e-rddr Pifl.ie
..
"'..'" II c"""
CQS siteadmin new page dialog
3. Open the newly create d Training Site page by double-clickin g it in the right
pane - then view its output to ensure it meets your expectations.
Copyright 2010, Day SoftwareAG . Switzerland Rev 1.5 20100907 www dav.com
•
Hello \Vorld I!! #,
('
"
4. Repeat this process until yo u have created a Web site structure similar to the
image be low.
• CQ5 WCM
~ -.J Web5I~
;!J _ caMpaig ns
;!J Dtglt)l Assets
.tI ;.J Gcomctnxx Demo Site
~ User GcncratCO Center'll
;!J ., Wrlo Content
~ i!) Tra nll'lg S,le
.:;I !) Engl.sh
!l Com:loa"Y
" £.l '£l
""""'"
Lawn Sprinkler
!l Clay PLant Corr..l ~'W
;i) Cust~
~ Espa'KII
NOTE
Since all Pages wi ll be created using the same Template (Le. Training (ontentpage) and
implement the same rendering script. every Page wi ll look identical - for now.
Copyright 2010, Day SoftwareAG , Switzerland Rev 1.5 20100907 wWW; day.com
•
EXERCISE - Install & Start CRXOE
Goal
T he foll owing instructions ex plain how to install and start CRXDE, Day's Eclipse
based IDE application. To successfully complete and understand these
instructions, you will need :
What is CRXDE?
CRXDE is a pre - packaged stand - alone Eclipse application. CRXDE i s custom -
built specifically for CQ and CRX and thus enables you to efficientl y develop
your project. CRXDE gives you a broad set of tools t o easi ly create and manage
fil es, fo lders , Tem plates , Com po nents , Dialogs, nodes , pro perties , scri pts and
OSCi bund les wh ile logging, debug g in g and integrating with SVN . CRXDE is
built on the Ecl ipse Rich Client Platform (RCP), leveraging t he Eclipse File System
(EFS) API.
1. Create /i den tify a f older structure on your fi le system where you will store,
instal l, and start CRXDE (e.g. C: / day / cq5).
2 . Copy the approp riate CRXDE package from < USB> / distribution / crxde into
the f older structure .
Password : •••••
Co"gratulatio",! You have successfully installed an d started CRXDE, Here you will
be able to create and modify CQ5 elements such as Tem plates, Components,
scripts, etc. In add ition, traditional ID E tools such as cod e complet ion and
debugg ing will now be avai lable to you , Be low is a vi ew of what CRXDE looks
like after start ing ,
'"
"
- Navigator ;
+ ~ apps
+ -£f .:.~~._.... ..................•
"" lR ,~!b$...... .
. .- .. .
,,~
,',
...... •• A. _~ '__........_ ·, .., - ..... .,,-,
,
CRXDE interface view
Goal
The following instructions explain how to use CRXDE to perform basic
development task s. To success fully comp lete and understand these
instructions, you w ill need :
.... """"
~.IIP
' ....
~
.e". ' ~~. _ ~l,, _ :l"'M
(
<_ott
.-..t<II
,--~.~tlI..l.
He l l O World'"
(
)
(
. ~ ..
." ..:<
" (
'.. ,--. ,-_...___ . . I'-'~ '" . _. . . ._ .;1'-._..•.. .../ -- ..-...... -' ' ../'"--", -.... -_. __ .... ,;.."\./ / '
NOTE
Traditional keyboard s hortcuts will work in CRXDE (e.g. Ctrl - S to save, Ctrl - C to co py, etc.).
3. In the CQ5 5iteadm in tool, navigate to and open any page that is based off of
this "Page·' Component to view your changes.
Co"gratulatio"s! You have successfully modified a script using CRXDE. For the rest
of t his training, you will use CRXDE to accomplish more comple x development
tasks.
Goal
The following instructions ex plain how to include an existing CQ5 "power"
script. This wil l give you access to numerous development objects, at
compil ation time . T o successfully complete and und erstand these instructions,
you wil l need:
The Day provided g/oba/.jsp declares the Sling, CQ and jSTL taglibs and
exposes the regular ly used scripting objects defined by the
The < cq:defineObj ects > tag exposes the following , regularly used, scripting
objects w hich can be referenced by the developer. It also exposes the objects
defi ned by th e < sli ng :defineObjects > t ag .
• componentContext
• th e current component conte xt obj ect of the request
(com .day.cq.wc m,api. components,Com ponentConte xt interface).
• component
• th e current CQS component obj ec t of the current resource
(com .day.cq.wcm.api.components.Component interface).
Copyright 2010 , Day Software AG, Switzerland Rev 1.5 20100907 www.dav.cQm
•• currentDesign
• t he current design object of t he current page
(com. day. cq. wcm.api .des i9 ner. Des ign inte rface).
• currentPage
• t he current CQ WCM page object (com.day.cq.wcm.apLPage interface).
• currentNode
• t he current JCR node object (j avax .jcr.Node interface) .
• currentStyle
• t he current style object of the current ce ll
(com.day.cq.wcm.api.designer.Style interface).
• designe r
• t he desig ner object used to access design information
(com .day .c q. wcm .api .desig ner. Des i9 ner interface) .
• edi tCo ntext
• t he ed it context object of the CQS compo nent
(com.day.cq.wcm.api.components .Edi tCo ntext interface).
• pageManager
• the page manager object for page level operations
(com .day .cq. wcm. api. Page Manage r interface).
• pag e Pro perties
• t he page properties object o f the current page
(0 rg .apache.sl i ng.api. resou rce. Val ueMap).
• properties
• t he properties obj ect o f t he current resource
(org . apache. sli ng .api. resou rce. Val ueM ap).
• resource
• the current Sling resource object (org.apache.s ling.apLresource.Resource
in terface).
• resourceDesign
• the design object of the resource page
(com.day.cQ .wcm.api .designer.Design interface).
• resource Pag e
• the resource page obj ect (com.day.cq.wcm.apLPage interface).
contentpage.jsp
<'@include file- M/libs/foundat ion/global.jsp "\ >
<html >
<he ad>
<title>Hello World !!!< / title>
</head>
<body>
<hl>Hello World ll! </hl>
<h2>Welcome to a new Day</h2>
<h3>Look at me, I am using CRXDE<!h3>
< / body>
</html>
4 . Test your script by requesting a Pag e in CQ5 Siteadmin that implements this
"Page" Component.
Goal
The following instructions explain how to dynamically display basic Page
content such as Page t itle , name, and pat h. This is an introduct ion of how to
ren der content that lives in the repository, which is a similar concept to
querying an d di splaying data from a data base. To successfully com plete and
understand these instructions, you will need:
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.dav.com
• • Via current Node object
• The current Node o bj ect is an in stance of the Node (see JCR API) clas s,
which provi des acc ess to content via the getPropertyO method. For
exa mpl e:
NOTE
Day does not recommend using t heJCR API directly in CQS unless nece ssary. Si nce CQ5 is a
Sling application. you should dea l w ith resources and not JCR nod es.
How to dYMa",ically display basic Page con teMt iMyour TraiMiMg 'Page- Co",poMeMt:
2 . Enter someJ SP and HTML code, simi lar to below - then Save.
contcntpage.jsp
<%@include file::"/libs/foundat i on/global.jsp"\>
< html>
<head>
<title>< %z currentPage . getTitle() : : null? currentPage.getName()
currentPage.getTitle() %></title>
</head>
<body>
<h2>properties</h2>
Title: <%- p r operties. get("jcr:title") %><br />
<h2>currentpage</h2>
Title: < %- cur rentpage.getTitle() %><br />
Name: <%: currentPage . getNarne() %><br />
Path: <%- currentPage.getPath() %><br />
Depth: <%- currentPage.getDepth() %><br / >
<h2>currentNode</h2>
Title: <%- currentNode .getProperty( "jcr :title") .getString () %><br />
Narne: <%- currentNode.getName() \><br />
Path: <%= currentNode . getPath() %>< br />
Depth: <%z currentNode.getDepth() %><br />
</body>
</html>
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.dav.com
•
3. Test your script by requesting a Page in CQ5 Sitead min that implements this
"Page" Com ponent.
• If success fu l, you shou ld now see content related to the reque ste d Page being
displayed dynami cally, similar to th e image below.
Company +
properties
Tit le: Company
currentPage
Title: Company
:-<ame: company
Path: lcontcntitraining/cnicompany
Depth: 4
currentNode
Title: Compan y
~ame: jcr:contcnt
Path: Icontcntitraining/cnicompany/jcr:coIltcnt
Depth: 5
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 WWW.daY.CQro
•
Day 2
EXERCISE - Create Multiple ScriptslRenderers for the
"Page" Component
Goal
The fo llowing instructions ex plain how to create and use multiple scripts /
rend ers for a sing le Component. This will all ow fo r multip le views of th e same
content, w hich is a huge proponent for us ing Sling. To successfully com plete
and understand th ese instructions, you will need:
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.dav.com
•
content node to resource type, from resource type to script and what scripting
vari a bles are ava ilab le .
"'....,
-----
lwi.k i.lS li ng .~ d it. lU!nl / richte xt?sirr Ie_true HTIP/l.l
/ l'< ikVSli ng
/ Nodi hu proplrilu
U1~ '!ii. tog ~f!~ou"Ct TYPh I I I/buk' ~1 1 "1i: c<l~o ... r(\1~ ... pe~T '"~
"1~I /!)Gge
tel Resource Type --.r-
.
"mi. "
1\
lut 'rr'p~-'%~)-,)':>e
b,~ 'c.fn rtIQrt. n-.: f \ \ e
\
Script location.
Script Nom ••
Ent'"lo~
~
htllll.eso
Wort T... . ••."
~ . tSp
).\It~
o
Script
Include Option,
S .1 "(;11Hl<!(
•
Sling cheat sheet - side I "
The following diagram explains all t he hidden , but powerful request parameters
you can use when deali ng with the Sling PostServlet, the default handler for all
POST requests t hat gives you endless opt ions for creating , modifying, deleting,
copyin g and moving nodes in the repository.
"1"II~l t".,.,. t~
"''10.;1 t\-.,.....
value_ <fu- ...;H_
<.~~ ~y«
~(lI ... ~-
." fllI\It,. type_
,,(ll .. ~ _
.""lI"· t~Pl _
<,ro"t tylX'>-
.:u'¢!u: t)~
• ~ -
<''''''ot
.,g-,,_ H'P"," val ...... " ..... '" typ" •
n"-,,.
"f '-- .
•
Sling cheat sheet - side 2
In Sling, and therefo re also CQS , p roce ssing is driven by t he URL of t he HTTP
request. Th is defi ne s t he content t o be displayed by the appropri ate scri pts . To
do th is, information is extracted fro m the URl.
protocol I~ : olltellt
ath telector extentlon
I-
suffix
I-
param(tl I
i
http://myhost/toolslspy .print.a4 .html I alb , x=12
Copyright 2010, Day Software AG , Switzertand Rev 1.5 20100907 www·da y.com
•
When the appropriate resource (content node) is located , t he re source type is
extracted. This is a pat h, w hich locates the script to be used for rende ring the
co nten t . The pat h speci f ied by the sli ng :resourceTy pe property can be either
absolute or relative to a configuration parameter. Relative path s are
recommended by Day as t hey increase portab ility.
All Sling scripts are sto re d in subfol ders of either l apps or /li bs, which will be
searched in this ord er. The fo llowing d iagram ill ustrates how a scri pt re so lution
is resolved .
..Jcontent/corporateljobsldeveloper.html {RequesO
- .-
(Repository)
"\
••
- /apps
ill,
--.,
.-
/jobs
••
•
/POST.jsp
/jobs .Jsp
/pdf.j sp
.-J
Iprint.jsp
~
•
T
•
"/content
Icorporate
•
•
t
••
/jobs
•• Ideveloper
•
•• }cr:conttnl:
slllll;ltlOurcrType = l'11l'j obs -,
• J
--. ....... - ---'
Sling request decompositi o n
Wi t h Sling , you specify w hich script ren ders a certain entity (by se tting the
sling :resou rceType property in t he j cr :co nte nt node). This mechanism offers
more free dom than one in which the script acce ss es the data entities (as an SQL
statement in a PH P scri pt would do) as a resource can have seve ral renditions .
Copyright 2010, Day Software AG , Switzerland Rev 1.5 201 00907 WWWda\l:CQm
•
If multiple scripts apply for a given request, the script with the best match is
selected. The more specific a matc h is, the better it is; in other word s, the more
se lector matches the better, regardless of any request extension or method
name match.
Pack"gt: uplorer = EJ
" ilPPS
.. geO'Tle lrnu:
~ h'
... Jobs
pru'" Int folderl
"'l- a4 '1'
b html.jsp
"-=' a4 . •1tm . S",
,}4 .JSp
'- C[T.jSP
_ Jobs .Jsp
htr'll .j sp
pnr:t .htm l JSP
,. etc - .
Copyright 2010, Day Software AG , Switzerland Rev 1.5 20100907 www.da Y. com
•
From this it can be seen that:
Folders (i.e. nodes of type nt :folder) take precedence over jsp file names
when resolving using selectors.
Only one selector in a file name has any effect - any files w ith names
containing two selectors don't ever get selected, but names of folde rs can
be used to match the selectors in the re quest.
Scripts wit h HTTP method names (e .g .,GET.jsp) is selected as a last
resort, (after the default script: jobs.jsp, in this case).
Scripts with names that include HTTP methods in addition to another
selector or extension in a .jsp file name are NEVER selected.
_.
1, Ri g ht-click / apps / < application name > / components / page / contentpage - -
t hen se lect New, JSP.
.
....
~"
"
"'"c=::: .. $ .,
2 . Enter the d esire d fi le "Fi le name" (html.j sp) in the dialog - th en select FiKish.
Copyright 2010, Day Software AG , Switzerland Rev 1.5 20100907 www·da v.com
•JavaServer Page
Creatlt a rot¥! Jwa~ Pac;Je
- _ ~ dJlP<!nt, f~deo l
"" Tl1JI.!!P: wi
t(mi .
1Ad¥.-.c:t'd » I
NOTE
html.jsp
<html>
<head>
<tit!e>Hello World !!!< / title>
</head>
<body>
<hl>This is the HTML script/renderer <fhI>
< / body>
< / html>
4. Repeat these processes for a script / renderer named m .html.jsp. Change the
text in the m .html.jsp script to read
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 WWW.day'CQro
• < hl > This is the MOB ILE HTMl script / renderer </ hl >
Re member to Save.
Mozilt. F
Goal
T he f o ll owing instructions expla in how to modularize a Compo nent into
mU lt iple scripts and incl ud e them at runtime, promoting Com po nent / script
reuse. To successfully complete and understand t hese instruct ions, you will
need:
Often t he q uestion is as ked : "Should I use <cq :include> or < sling :include > ?"
When developing CQ5 components , Day recommend s that you use
< cq :incl ud e / > tag . This allows you to directly include script f i les by their name
wh en using t he scri pt attri b ute. This takes com ponent and resource type
in heritance into account, and is often simpl er than stri ct ad herence to Sling 's
scri pt resolution using selectors and extensi ons.
1. Remove (or rename) t he scripts hrmf.jsp and m . hrm f.jsp from your "Page"
Component by rig ht - click ing them - th en select Velete.
2. Create a new JSP f ile named body.jsp in your "contentpage " Component.
<h2>currentpage</h2>
Title: <I : currentpage.getTitle() %><br / >
Name: <%= currentPage.getName() %>< br />
Path: <%= currentpage.getPath() %><br />
Depth: <%= currentPage.getDepth() %><br />
<h2>currentNode</h2>
Title: < %::: currentNode.getProperty("jcr:title").getString() %><br / >
Name: <%= currentNode.getName() %><br />
Path: <%= currentNode.getPath() %><br />
Depth: <%= currentNode.getDepth() %><br />
</body>
NOTE
Not ice the fact the g/obal.jsp file has been incl uded at t he top of th is script. Si nce t his script
wi ll be included at runti me. it will be unaware of any previous includes of t he g loba l.jsp.
3 . Open the f ile contentpage.jsp, and enter some JSP and HTML code, similar to
below, replaci ng t he < body> section - t hen Save.
contcntpagc.jsp
<'@include file"''' llibs/ foundation / global. j sp" %>
<html>
<head>
<title><' z currentpage.getTitle() null? currentPage.getName{)
currentPage.getTitle() '></title>
<I head>
</html>
4. Test your script by requesting a Page in CQS Siteadmin that implements this
"Page" Component.
World Standard Software to Unify Your Business 49
Goal
The following instructions explain how to initialize CQ5 WCM, enabling use of
t he Sidekic k and othe r content management tools. These tools will al low
content authors to work more efficiently. To successfully complete and
understand these instructions, you will need:
1. Open t he file co"te"tpage.jsp, and enter some JSP code, similar to below,
add ing to t he < head > section an include of the initialization script - then Save.
contentpage.jsp
<%@include file:.:" Ilibs/foundation / global. jsp" %>
<html>
<head>
<title>< %c currentPage.getTitle() ;: null? currentPage.getName()
currentpage . getTitle() %></t itle>
<cq:lncluc1e scrlpt-"/libs!wcm!core/components/init/init.jsp"/>
</ head>
</html>
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 wwwdaY-com
•
2. Test your scri pt by requesting a Page in CQS Siteadmin that implements this
"Page" Compo nent.
• If successful, you should now see the Sidekick appear, which wi ll give authors
the abili ty to manage content.
,"-'y +
properties
Title: Conpany
currentPage
Title: Conpany
Name: conpany
Path: /content/tralntngSiteJen/C041panv
Depth: 4
currentNode
Title: Conpany
Name: Jo :c.ontent
Path: !content/trainlngSitelen/conpany/)Cf:content
Depth , S
NOTE
For developers of previous CQS versions, you will notice that the location of the init.jsp has
moved from / fibs/wcm/init/inir.jsp to its current location.
Co"gratulat io"s! You have successfull y initialized t he WCM, and all of its related
tool s. Again, this initialization is critical in enabling numerous CQS tools,
allowi ng content authors to work more efficiently.
Goal
The following instructions explain how to extend an eXisting foundat io n
component, a Day recommended best approach, inheriting its resources thus
allowi ng for script / Dialog reuse. To successfully complete and understand
these instructions, you will need :
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 wwwdav,cow
•
, - - - - -- - - --
to: apDS
+ geometllx'I(
..•
"- page
+ 1jlI
,-,_.
_cQ_nfoProviders
\... training + dialog
components s.google.)Sp
I'•
~ cor~,coe~n~t~~~~~~~~~~~~~~~~~ ~~~~
body. JSP
0·9' 0 .01 t.l'P •
,•,
__
L CQ:C head. lsp
body. ISO ' Img .png.,a¥a
-~rm;;:pa;;;ge.l'p r' naVlmaQe.pnQ .)aVa
t
;I'
inStall J page .)Sp
' •• . • J' _._~ .... . . ere
.......... _" ,...J
.,. - ."~' ft....... J
.. . . portlet. html .lsP /'
redirect ,J$p ,
...
scaffoktlng.JsP
stats.jsp I
'.
Non-inheritance of local copy
• Co ntainer Hierarchy
• This is used to populate co nfig uration sett ing s to the child com pon ent
and is most commo nly used in a paragraph system scenario. For
examp le, configuration settings for t he edit bar button s, contro l set
layout (ed itbars, roll ove r, etc.), Dialog layout On li ne, fl oating, etc.) can be
defined on the parent Component and propagated to t he children
Components.
• Configuration se ttings (related to edit functionality) in cq:ed itCo nfig and
cq :childEditConfig are propagated.
• Include Hierarchy
• This is imposed at runtim e by t he sequence of incl udes.
• This h ierarchy is typically used by the DeSigner, whi ch in turn act s as the
base fo r various design as pect s of t he rendering ; including layout
information , CSS informatio n, t he available compone nts in a paragraph
system, et c.
--'"
- -F. apps
.. geometrb(x
Pac~ EYPiof el
l,... hamlOg
components
content
Node
Ctr!+c t
Template-
~c
': omponeot
T t emp lat f'~
Ie Delete Delete Dialog
, ~E. ~.... . .A!"'" -- " - --" """ " '_ •• ,M»v.e-:::'· '\ .,.1" '" .
t t' Ibs 0.. . . ....... I"?
.:...kill.2.
!
Create new property
Enter riol'll'lOtion about tt-.e new Pl'operty
Type: strllQ
v&lue: fOll"l&i:IOI')/componerotsfpaoel
You can view this property, and others direct ly related to the Training "Page" Component, by
simply selecting and refreshing the "Properties " tab located at the bottom of CRX DE.
Problems ~ Console
,_
P1"op~ti~s
IrIo
N_
-cq:isContarlef
jc:r:cl eated
,.....
...
2OO9·12-02T10:58:2'1 .390-05:00
BooiO~-
0.<.
ae.xl .
-'. . ---r
Auto
true "
St•.., tnJec
"""'' on "r:createdBy
j(r:desotptlOn "*""
N' "'.... fal~
true I
JCf :plW'l\ar'y T)lpe
j(t:tltie
CQ:Coroponent
lr~ Contentp&ge ""'"
"'....
St• ..,
false ,/
sIing : '~CU"e5upe:T Type fOU'ldatIon'(om~nts'~ f~l~
,. ... ......
~~
. /~ "
-",. . ...,.. J ' . 1
3. Ope n t he fil e eontentpage.jsp, and enter some JSP code , similar to below,
removing the < head > section and including the head .jsp script that we
in herited f ro m t he foundation "Page" Component - then Save.
contentpage.jsp
<%@ include file"""/ l ibs/foundation/global . jsp "'>
<html>
<cq : include script- " head.jsp " />
• If succe ssful . you sho uld see no d ifference between what is dis played now, and
wh at was d ispl aye d before.
• You can also see that the "Page Prope rt ies" funct ionali ty is now availabl e in your
Sidekick, since we in herited the Dialog from the foundati o n "Page" Compo nent.
Copyright 201 0, Day Software AG, Switzerland Rev 1.5 20100907 Www day.CQm
•• CQS eM
v ..
Page Properties . . ,
Delete Page
Activate Page
Lock Page
Show References . . ,
Goal
The fo llowing instructions explain how to add additional structure to the
existing Trai ning "Page" Component, again allowing for resource reuse . This is
merely an extension of a previous exercise w here you added t he < body>
section of the "Pag e" Com ponent to a new scri pt (body.jsp), and then included
th at script. To successfully complete and understand these instructions, you
will need :
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.da~CQm
•C Navigator
R apDs I
.. L="" geometrixx
- C tr01nmg
componerts
i.
content
j
page
- i", e ..1..·]l(.g.· .f
body. )Sp
".!.:Ok..
.•
center, lSP
(ontentpage .j5p
left .J:;p
.•,
nght .Jsp J
irr~ aI
' .. . ...
~ ~
" ... ., ~"" ~,,.."" .......... r'-'
2. Open the file left.jsp, and enter some HTML an d JSP code, simi lar to below-
then Save.
Mt.jsp
<\ @include filez" / libs / foundation / global.jsp "%>
<div c l ass= "left">
<div>logo< / div>
<di v>newslist< / div>
<div>search</div >
</ d iv>
3. Open the file center.j s p, and enter so me HTML and JSP code, similar to below
- then Save.
cell ter.j sp
<Uinclude f ile=" I !ibs / foundation / global. j sp "%>
<div class="center">
<div>trail< / div>
<d iv>t itle</div>
<d iv>par</div>
</ div>
r ightjsp
<%@include fil e"" "i h bs/founda tion/global .jsp" %>
<d i v class="right ">
<div>rightpar</div>
< / div>
5. Open the file body.jsp, and enter some HTML and JSP code, sim ilar to below -
then Save.
hody.jsp
<%@include file = "/libs/foundat ion/globa l. jsp" ' >
<body>
<d i v class: "topnav ">topnav< / div>
<d i v class "''' content">
<cq:includ e script= "l ef t . jsp" / >
<c q: include script= "c e nter. jsp " />
<cq :include script= "r ight . jsp" / >
< / di v >
<div class = "foo t e r">
<di v c l ass= "toolbar "> t oolbar< / div >
<di v c l ass",ndiscla imer ">d isc l aimer < / div>
< / d iv>
</body>
• If succe ss ful , you should se e a simple text out put (which we will fi x soon) of
wo rd s and the Sidekick, simi lar to the image below.
Co~ gratulatio"s!
You have add ed add itional stru cture to an existing Component,
promoting reuse in your develo pment efforts. Again, Day feels it is impo rtant
you become we ll ve rsed in t his capability / techn iq ue, as it wi ll allow you to more
easily reuse Components in the fu ture. Now let's make the output more
attractive by introducing you to Designer functionality.
Goal
The fo llowing instructions explain how to create and assign a Design(er) to a
Web si te structure, allowing you to separate content and design, wh ile
promoting a consistent look and feel across many Pages. In the interest of time,
we wi ll create a new Design(er) f or Trai ni ng , bu t copy th e exis t ing static. ess f ile
from the Geometrixx Design(er) . To successfully complete and understand
these instructions , you witl need :
CQS has been deve loped to maximize com pliance with the Web Accessibi lity
Guid eline s. Web accessi bility mean s t hat peo ple wit h d isabilities can percei ve,
understand, navigate, and interact with th e Web, and t hat they can contri bute to
th e Web.
Thi s can include measures such as provid ing textual alternatives to images (or
any non - text item). T hese can then be used to hel p people with sight
im pairment by outputting the text on a Brai lle keypad, or th roug h a voice
synthes izer. Suc h measures can also benefit people with slow internet
connections , or any internet user - whe n t he measures offer t he use r more
information .
Such mechanisms mu st be carefully p lanned and des igned to ensure that t hey
provide t he information requ ired f or th e user to successfu lly understand and
How to create a Pesig~(e rl for your Web site. usl~g CQ~ S iteadllli ~:
Too l s
,-------- - -- -- - -- - -- - - - - - .,
••
CQ5 WCM
J -1
<b ~ -..
New...· Copy
"
.<
Deletf..
"
....... ~
"
Copyright 2010, Day Sofiware AG , Switzerland Rev 1.5 20100907 wwwda\l: com
•
2 . Se lect th e "Designs" f ol der - then se lect New.... New Page ...
• CQSWCM
~
•
~ New ... • Copy Dele
'.
4
L....':f
Calendar
blog
,.;•
.±J'!:.J Geometrixx O.:mo Site
';!) CustofTl Documentation
~_ M
.,.
.... ,._.'.'{( \ Jb . ..... ~'-··\. /.
.. .... . ,"·..-.,.,r
_.. . , . . ,..~ .
~'"
~ . - .~ ........
3 . Enter the Design(er) "Titl e" (Traini ng Design) and "Name" (training Desig n) in
the dialog - then select Create.
•
•
If you believe your implementation will have more than one Oesign(er), which is quite common,
it is recommended you create a design structure that wi l l all ow multiple Design(er}s to be
as sociated with the one project.
4 . Se lect the "Geometrixx" Des ig n(er), afterward selectin g the static.css and the
images fo lder- t hen select Copy.
J -... 'l
=t l oo1s
T'" ,..!
~
~
_ 6kJeD"nt~
DeSiQns
I """" m{
jJ Blog st"tlc:.css static:.r
~ !... Calend!r to"';
:.J Dd d [ ·eSlQO ~ ...r'
1 GeomebI)JI' Demo Site
.!.l_ ~
I\
....J st~It. (SS :;;..
, , '-.,.. __ .tr" . 'q-~..-,~~~ ", ·./lA...·." • • F' ... . _ .. J""... ........,.._/· - ,·.,·..... _ ./~
••
- --
CQ5WCM ., w
......
- .....
" - ' Tools
::J B1..e::r-n:.
J
.
_
~
"!.l ~
!.l Od:1At Deog~
.>1~ Go!or1ct:'.q. ~'I'III Siu:
~'!J ~!:leoq.
Copyright 2010, Day Software AG , Switzerland Rev 1.5 20100907 www.da v.cQm
•
Co~gratulatio~ s!
You have successfully created a Trai ning Design(er). You can
easily modify the static.css f ile by usi ng CRX DE and going to / etc / desig ns /
training. Now t hat we have a Des ig n(e r), the next task is to assign that Design
(er) to our exist ing Training Web site structure.
W eb s ites
Cr-=:ate: a d r(\Qnaq~
mult pIe wet-sites
• CQS WCM •
~ New ... y Copy !"
.'
..
Delete Page
Locl. Po1l~
Ad ... anr ~d
01 Cancel I
Page properties dialog - design selection
World Standard Software to Unify Your Business 67
Copyright 2010. Day Software AG, Switzerland Rev 1.5 20100907 www·da v•CQm
•
5. Select t he newly created Trai"i"gPesig" Des ign(er) - then se lect OK. OK.
~ ...J/e'-C.'d(,ggm
J:I_, OIog
;1:1 - ' c"k:nd.tr
WOef.uit 0cs09~
OK II "-'
Design selection dialog
------ .-
•
~ .; ~ w:
,
,
,
)
.-,)
"'4' ('"
__ .J-,._ '."' ........ _..... f-'" " . . .. __ r'-- "or -'.-_,r·~,. r -- ...... r ..· '\.1",)
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.dav.com
•
EXERCISE - Create a Text-based Navigation
Component
Goal
The following instructions explain how to create a dynamic text-based
navigation Compon ent, allowi ng for Web site structure to be easily mod ified
and represented / navig ated in real-time. To success fully com plete and
understan d the se instructions, you will need :
1
traiOlng
3
dientes company products customers
• com.day.cq .wcm.api.Pag e
• com.day.cq.wcm.api.Page Filter
labet: topoa..
Title:
NOTE
This Is a si m ilar proce ss to the "PageR Component we created earlier using CRXOE Lite.
3. Open t he file topnav.jsp, and enter some HTML and JSP code, similar to
below - t hen Save.
topn3v.jsp
<%@include file"'"/libs/f oundation/globaI.jsp"%>
<\@ page i mport"'''java.ut il.Iterator,
com.day.cq.wcm.api.pageFilter" %>
<i
II get navigation root page
Page navRaotPage ~ currentPage . getAbsoluteParent(2);
if (navRootPage != nUll) {
II create an iterator object of all nav root's child pages
Iterator<Page> children = navRootPage .listChildren (new pageFilter());
.>
4. Open the file body.jsp in th e Training Contentpage Component and replace
th e "topnav" < div> section with a < cq :include > of the navigati on Component
you just created , simil ar to below - then Save.
• path
• The path to the resource obj ect to be included in the current request
processing. If this path is rel ative, it is appended to the path of the
current resource whose script is including the given resource.
• resourceType
• T he reso urce type of th e resource to be incl uded . If the resource type is
set, the pat h must be the exact pat h to a resource object: in this case,
ad ding parameters, selectors and extensions to th e path is not
supponed .
• If the resource to be included is specifi ed wi t h th e path attribute that
cannot be resolved to a resource . the tag may create a synthetic resource
obj ect out of the path and this resource type.
bodyJsp
<%@include file= M/ libs/foundation/global.jsp" %>
<body>
<cq: include pa th-" topnav" resourceType-" training I components 1 content 1
topnav " I>
<div class: Mcontent ">
<cq:include script="left.jsp" I>
<cq: include script= "center. jsp" I >
<cq:include script= " right.jsp " I>
</ div>
<div class="footer">
<div class=="toolbar">toolbar< / div>
<div class="disclaimer ">disclaimer</div>
</ div>
< / body>
Copyright 2010, Day SoftwareAG, Switzerland Rev 1.5 20100907 WWWda YCQm
•
5. Test your script by requesting a Page in CQS Siteadmin that implements this
Trainin g "Page" Component.
• If succe ssful, you should see navi gatio n lin ks / tit les directly re lated to your We b
site structure.
,--------------------------------------,
Company
'"'. .'
CQS WCM
... .
<.
Copyright 2010, Day SoftwareAG , Switzerland Rev 1.5 20100907 WWW·da llcom
•
EXERCISE - Add a Log Message
Goal
Th e f o llowing instructions explain how to add a log mes sage to a Component
scri pt . Thi s will allow you to more easily debug various scripts you may be
working o n. To successfu lly complete and und erstand these instructio ns , you
will need :
• log level
• Thi S is provided by the cor re spond ing method call. For example, a
lt
log.debug«message» produces a message with log level "debug , while
a log.info«message» produces a message with log leve l "info". Pos sible
metho ds of the HLogger" object in clud e:
• traceO
• debugO
• infoO
• warnO
• errorO
NOTE
In a default configuration, the log file is located under <cq-insta il -d ir> / crx-quickstart / iogs l
error .Iog.
1 . Open the file topnav.jsp in the Training "topnav" Component. and enter
so me J5P code. similar to be low - then Save.
topna\'.jsp
<% @include files" / libs / foundation / global.jsp" %>
<%@ page import"""java.util.lterator,
com.day.cq.wcm.api.pageFilter" %>
<.
I I get navigation root page
Page navRootPage % currentPage.getAbsoluteparent(2);
if (naVRootPage 1= null) {
II create an iterator object of all nay root's child pages
Iterator<Page> children = navRootPage.listChildren(new pageFilter(»i
while (children.hasNext(» {
II get next child page
Page child = children.next();
II new log message -- logging title of nay page
log .info("child page [{}J found.", child.getTitle(»;
I I display the link in an <A HREF .. .
%><a href="< %= child.getPath() %>.html"><%=child . getTitle() %><1
a><br 1><%
}
.>
• If succ essfu l, you should see no differe nce between what is displayed now, and
what was di splayed before. However, if you were to inspect the error.l og file.
you woul d see a me ss age similar to below:
Co~gratu latio~.! You have successfully added a log message to your script. Again ,
it is often crucial to monitor the values of variables assigned / used. The
"Logge r" object is a useful tool that will enable you to do so .
NOTE
In CRXDE you can display the f ile error.log that is located on the file system at < cq - instaU -
dir>j crx-quickstart / server!logs and filter it with the appropriate log level. This ca n be done by
proceeding as follow s in CRXDE:
I . Se lect the Co"sole tab locat ed at the bottom of t he w indow - th en se lect the arrow besi de the
Ope" Co"sole - th en se lect SysteIM Log.
•••
1 \lerston Control
'.
CRXDE console applicati on log selecl
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www-ciallcom
•
2. Se lect t he desired ~ I og level" in t he drop down m enu.
• The error. log is then filtered according to the log level and displayed in th e tab .
....
Info v
trace "
oppecl for
debug
"I'====~,at.
n flgUraCl o 1'warn d at / etc/r~~ l :
ion
dated. St a error abled
arted .
~ agent- "a.c... /-ete)'..rep 1 i a: ac iel't/ agent ~
' " . .....A _ ' . '
Goal
T he foll owing instructions explain how to enable the debugger in CQ and
CRXDE. This will allow you to more easi ly debug various scripts you may be
working on. To successfully complete and understand these instructions, you
wi ll need :
2. Navigate to the directory where the Java servlet engine (CQSE) has been
installed using your command line.
NOTE
By default , port 30303 will be used by the server for debugging communication. You can
customize the server. bat / start file for future use . In addition, you can call the debugger directly:
4. Start CRXDE.
6. Rig ht-click the left-s ide of the JSP edi tor on a line of cod e {e.g. line 13: if
(navRootPage != null) {) - then select Toggle &reakpoi"ts .
,
~t ( n ..v Roo tP .. ~ .. ,- ..... U ) I
,r
J.)
_.
Addr..... .
"~.
,-
C_ e - '
• III ( <> un<l . " , c h.l d .9CtTHleOI;
•
• etP&thO
r
/
('
l- l1 port .. ·'J "ltd . It .,.Cd r "
t,'· ,1.j .
)
c :W:. dd1'. cq. :.'·:rn. ~...
'P'" I
.. ge~tll.a:
(
''''''''l P&ge ne.vRoo1;.Page '" cun:entPage. t.
8. Enter the de bug po rt (3 0303) used for starting the server in debug mode -
t hen se lect OK.
Enter the debug port ~d for st~tno the server Ifl debuo mode
303031
or, kJ I C, ,,,ol
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 Www·day.com
•
NOTE
You are now in debug mode. Yo ur CRXDE view shou ld look sim ilar to the image below.
-
'*""_....._ - - - - - - - -
*' __..,0-__ _
-.-......,--.~
··--I-(""""",",~->l-
•• _ _ II~"t '_>I_
". ....... .•.
~ ~-.-.I
- •
c
..•-""...,-,.....-"'--
1 _'
, - ,.... . (0001-' .......
,. _ l... _·_ _" _.....
- _ _ 1_ _ _ "_1_
......
[-,,-~~,
'? _ _ I'_"'_"_J_
,- _ _ [_"1,_
""--_''''-'1-
·--1-_--.
.- _._ _-
~
. . .--
~ _ _ ("'''''_I\O''·.-..l
" _ _(INff_I_
........
."...._,..-.....0]_
_ __,........,;J_
_'~_,
..... ..
-- --- ___ ___ .....o
---*~=:=:'t:;-
~
.-
. ~ ........... --...').,.,-
" , .......... ~_ -- _ I I " n."u"_ " _"\ , •
_ o"""p_ • ~"-fO"'_'
" ~ _,_ •• - " ' 1 1
-
.... l~ ( e •• ' ..... . ~ . . ) ' I
---
CRXDE debug mode
__ n ·
9. Tes t your script / debug mode by requesting a Page in CQS Sitead min that
implements this Trai ning "topnav" Component.
• In CRXDE, you will notice your script stops at the line of code containing the
breakpoi nt
• Here you will be able to investigate variables, execution, and other related
elements , in add ition to "s tepping " throug h your cod e
Goal
The following instructions explain how to create a dynamic image-based
navigation Component, allowing for Web site structure to be easily modified
and represented / navigated in real-time . To successfu lly complete and
understand t hese instructions, you will need:
You wil l need to add an image processing scri pt or Java servlet t hat wi ll handle
all req uests with the specific selector "* navimage .png'·. For the rendering of
images with an overlay o f text, t he abstract Java servlet Abstractlmage5ervlet is
World Standard Software to Unify Your Business 83
For more detai led information concerning the AbstractlmageServlet and other
Day related image processing capabil it ies, please review the CQJavadoc
provided with CQ WCM and on your USB.
•
....e.g. / apps / training / component s/ pag e/ contentpage
..;
.f c. .~.~r-- .... ~ ..... "./' v,,· ----
CRXDE structure of contentpage component
WARNING
It is possible yo u will need to modify the Java package to match the current location of the
Tra ining Content page Component.
• e.g. apPs,training.components.page.contentpage
topnav.jsp
<% @include file"' ''/ libs / wcm/ global . jsp'' %>
<% @ page import:"java . util.lterator ,
com.day.cq.wcm.api . pageFilter" %>
<.
II get navigation root page
Page navRootPage = currentpage.getAbsoluteParent(2);
if (navRootPage != nUll) {
I I create an iterator object of all nay root's child pages
Iterator<Page> children = navRootPage.listChildren(new pageFilter(»;
while (children.hasNext(» {
II get next child page
Page child z children.next();
II new log message -- logging title of nav page
log.info(nchild page [(}) found. n , c h ild.getTitle(»;
II display the link in an <A HREF •..
%><a href_ <%_ child . getPath () \ >.html"><img alt-"<\- child . getTitle
M
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.daV.com
•
4. Test your script by requesting a Page in CQS Siteadmin that implements this
Training "Page" Com ponent.
• If successful , you should see navigation li nks/ titles di rectly related to your Web
site structure.
COKgratulatioKs! You have successfully modif ied an existing "con t ent" navigation
Com po nent t hat dynamically re presents the navigat ion structure of your Web
site using images.
Goal
The following in stru ct ions explain how to create a Component that allows
authors to manage a Page 's title (te xt ua l content), t hrou g h the use of a simple
Dialog . Thi s is a beginning step in learni ng how to create Componen ts t hat
allow au t hors to write content. To successfully complete an d understand these
instructions , you will need :
What is a Dialog?
During t hi s trainin g you have fo cused most ly on rendering content (static and
dynami c), which is important as one cou ld argue it comprises 50% of w hat yo u
do as a CQ5 deve loper. What needs to be accompl ished for this exerc ise is to
provide content authors the abi lity to w ri te content. You can accompl ish this by
learning how to cre ate a Componen t Dialog . A CQ5 Dialog is sim ilar to oth er
dialog s you have used / created in t he pas t : it gat he rs user input via a "form",
potentially validates it, and then makes that input available f or further use
(storage, configurat ion, etc.).
In re lation to the Component the Dialog is being created for, the root node of
the Dialog has to be of node type "cq :Dialog" and named "dialog". Be low this
Dialog root node, the nodes for the tabs of the Dialog have to be ad ded . T hese
World Standard Software to Unify Your Business 87
l~:
Title:
[)esc."...,
~ Rrso..rce Type:
Gr~:
NOTE
2. Open t he file tit le.js p, and enter some HTML and J5P code, similar to below-
then Save.
tiUe.jsp
<%@inc l u de file= ~/ libs / foundation /g lobal . jsp "'>
<hl><\s properties.get( ft title", currentpage.getTitle(» %></h l >
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.day.com
•
NOTE
You will notice t he use of the Sling Va lu eMap clas s / object "properties". Thi s object allows you
to easily get properties associated with this instance of thi s Component.
centcr.jsp
<%@incl ude f ilem"/ !ibs / foundation / g!obal.jsp" %>
<div class= " center">
<div>t rail </ div>
<cq:include path- " title_node M resourceType- "t raining/components/content l
title " />
<di v>par< / di v>
</div>
4. Test your script by req uesting a Page in CQS Sitead min t hat implements this
Training title Component.
• If successful , yo u should see th e defaul t Pag e titl e, simitar to the image below.
• CQ6NLM-'" ..
I;
f
--
Tide; II........., Ttie CcrrcIonerI
NOTE
Now is a good time for you to review the Dialog / node structure, and be able to easily map the
related elements. Please review the image be low for a better understanding (image is a
completed Dialog - you are not there yet).
- -"'-
-.----,....--._... ---_.
-.....
..............
,,-'....
!.
I"'a,,_ ..
~.-
_"~)
f
-.......- -, •
,""""
"'" di~
:-- it~rrrs
". ". .. C"
t"
I
(
F",h I, C""d
(
(.J
,
CRXDE new node dialog
• Name = title
• Type ~ cq:Widget
10. Right-click the newly created title node - then se lect New. Property.
11, Enter the desired "Name", "Type", and "Value" for the properties listed
below.
Copyright 20 10, Day Software AG , Switzerland Rev 1.5 20100907 www.da y.coro
• • the property that will define the Widget type (Le. user interface co ntrol)
• Name = xtype
• Type = St ring
• Va lu e = textfield
• the property that will defi ne the label applied to the Widget
• Name ~ fie ld Label
• Type = Strin g
• Valu e = Enter T itle Here
NOTE
These are but a few of the many properties and Widgets you can use to create a Dialog that
meets the needs of yo ur users/ conte nt authors . You ca n find a complete listing in the provided
CQ-WIDGETS -API on the USB .
(
I
• Company l
.. -'
Page title content se lect ion
•• •
Dialog of title
World Standard Software to Unify Your Business 92
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 wwwday.com
•
NOTE
Notice how tabl 's label is "Tab 1." If you wa nt to change this value. simp ly assign a property
named t it le (type String) to the tab 1 node, and assign a va lue.
• If success fu l, you should see the cu stom Page tit le. sim ilar t o the image below.
~
~
,
.;
./
•
" •. ,
.... ~~ .... I
" " ... . r " '.
\ •.., ·L .... ..
~--' . r
·· /i ",
..... ....,._..... /
Page view with custom title
Co"gratu latio"s! You have successfully created a tit le Component, with a Dialog,
that allows content authors to write content and have it displayed. This is a
sig nificant step in your d evelo pment capabilities, as you are now able to create
CQ Components that allow you to write content to the repository.
Goal
T he f oll owing exercise tests your knowledge of component creation and taking
input from an author. Th e goal is to create a Lis tChildren compo nent. To
successfully com plete and understand these instructions, you will need :
2. Get a list root property (should be a path) whose value will become the root
of the list
3. If the list root property is empty, use a default. ( static path or path to
current page )
9. Place an input widget on the dialog box so the author can enter the list root.
10. Edit /eft.jsp. Replace the placeholder for news list with a (cq:i.clude> of your
new component.
Co"grat ulatio"s! You have successf ully created a listChild ren Component, with a
Dialog , that allows content au t hors to enter content and have it used as a list
root . T hi s is a significant ste p in your deve lopment capabilities, as you are now
ab le to create CQ Components t hat al low you to write content to the repository
and use that information to create new ren dered content.
Copyright 2010, Day Software AG . Switzerland Rev 1.5 20100907 www.da )t com
•
Oay3
EXERCISE - Create a Logo Component
Goal
Th e fol lowing instructions explain how to create a Com ponent that allow s
designe rs to manag e a Web site' s logo (bi nary content), t hrough th e use of a
Design Di alog. By using a Design Dialog , it wi ll ensure the dis played logo and
rel ated link are consistent f or all Pages that use t he same Templ ate / Design. To
successfully comp lete and understand these instructions, you will need:
Label: logo
Group:
NOTE
When using the Dialog Widget smartimage , as you will to complete this exercise. it is
recommended to extend th is "he lper Component . It contains the Java source img.GET.java,
ft
w hich allows you to more easily manage / transform images in fewer lines of code.
2. Open t he file logo .jsp, and enter some HTML and J5P code, similar to below-
t hen Save.
logo.jsp
<% @include f ile"'''/libs/foundat i on/global .j sp''%>
World Standard Software to Unify Your Business 97
<.
String homePage .. " .,
Page parentPage currentpage.getAbsoluteParent(2):
if (parentPage == nUll)
if (imageResource ! = nUll) {
/1 "c ast" resource as image
Image image = new Image(iroageRes ource) ;
if (!image.hasContent(» {
1/ if image has no content, write out "Home Page"
%> Home Page< %
} else {
II if image has content , set selector , draw out
image. setSelector(" . img ") ; / / use inherited image script
image.draw(out);
} else {
%>Home p age<%
}
.>
<fa>
3 . Open the fil e left.j sp in the Training Contentpage Com po nent and re place
the "logo" < div> section with a < cq :includ e> of the logo Component you just
created, similar to below - th en Save.
Icft.jsp
<%@include file:"/libs/found at ion/9lobal . jsp ~% >
<div class="left">
<cq:inc l u de path- " logo" resourceType= ~ trainin9 / components/content/logo M />
<div>newsl ist</div>
<div>search</div>
</div>
World Standard Software to Unify Your Business 98
Copyright 2010, Day Software AG , Switzerland Rev 1.5 20100907 www.dav. com
•
4 . Test your script by requesti ng a Page in CQ5 5iteadmin that implements t hi s
Train ing logo Component.
• If successful, you should see the default logo output, similar to the image
bel ow_
Custome rs
~
•.. <'<
,
,
f
Customers
-;J
.i'
)
N¥ne; de->q\_WbO
rille, l r~L09OC~
8. Assign the foll owi ng properties to the newly created margin node :
10. Ass ign the following properties to the newly created absParent node:
11. Copy the no de / Iibs / fa un d atian / ca mpone nts / image / di a lag !items / image -
then paste to the logo's Design Dialog so that it is a peer of tab I.
• e.g. I apps/ training / co mponents / conte nt j logo / desig n_d ialog / it ems / items
NOTE
Instead of always reinventing th e whee l, it is often more efficient to copy- and- past e existing
Dialogs /Widgets that meet your needs . That being sa id, it is wise to review w hat yo u have just
co pied to better und e rstand the intern al workings of CQ.
In add ition, you may have noticed this Widget was pasted in the location where tabs a re
typically located. The smartimage xtype (along w ith a few others) is unique in that it provides a
better conte nt author experience when ~cas ted " as a tab.
"-
(lop!' N ""net...
ddGf~
Yo'"
.(rM>]eCrop
~d •
Type
Str rl9
''''''
,.,•
r.
ft~"'r <llTl!"(er
fief!.ef eT'eno:: ef:'",,-an-.el.:er
.Ifdet./afne
./filePefr;<erv:e
~m,
st,,,, ,
t(l:~t N~
-
P :prl'MryT.,.-pe
mapP6Iamet~ . rm.q-t·~
.jJiIe
Strr-IQ
st,..., Ii,.
rendibons../fu; I JCr _content{rendlboos{cQ'SdaM._ ... stri'Y,J I
.eQtJe"'"..tSdfrs. . ~.pnQ
"'''''
,c.t¥.eP<!Ir.yneteo
"'.
....,..",
,-
. /mqRot~e
(tmpJlI()lo.ld _test/'
5.""
st""
,/
r
. _. • ~-,-....- .- . ~_.".'II'" ". ...r'" ./ .... '. . . . ~ ..... ~.,--...-..-.\.!'.. / ..'.- Y"~ / "
CRXDE properties of image widget
• .,
5 C
. .
!J v
-- ,
,
J.
'.
Copyright 2010. Day Software AG, Switzerland Rev 1.5 20100907 www;dav.com
• Com pa ny
, ,PRODUCTS 'h
..
~------------~----------t-,-'-~--~
Ejt
--"-'
'C) This is 2t,-
, ,
~ .•.. .'~'
.. . ..
Page dialog edit bar
: ••- geometrixx
••• • shapes for ccnt:mcs
' - _H-'.
elp
' ----.JII,_ _ _-.JIIL ---''''---.JI [ Car.:el
• If succe ssful , yo u should see the custom Page logo , similar to the image below.
Company Image (Unnamed - com .day.cq .VKm:cq ..
,
~
geomeulXX ,
• snapes tor a:m.r.os This is a custom TITLE ,
par
I
..... ~
Copyright 2010, Day SoftwareAG, Switzerland Rev 1.5 20100907 WWw da v.CQm
•
EXERCISE - Include the Foundation Breadcrumb
Component
Goal
The fo llowing instructions explain how to include the foun dation Component
the Breadcrum b, w hic h allows designers to dynamically manage the dept h at
w hich a breadcrumb trail be g ins. This exercise will rei nforce your abili ty to
includ e existing Co mponents into a Te m plate . To successfully complete and
understand t hese instructions, you will need :
ccntcr.jsp
<%@include file= M/ libs /foundation/global.j sp N% >
<div class = "ce nter M>
<cq:include path= Mtrail M resourceType= " foundation/components/
breadcrumb " />
<cq:include path="title" resourceType="training /components /content /
title / >
M
<div>par</div>
</div>
NOTE
As always. it is a good idea to review what you have just included. Take note of the fact this
Component on ly co ntains a Design Dialog (i.e. design_dialog), thus can only be modified in
Design mode.
2. Test your script by request ing a Page in CQ5 Siteadmin that impl ements this
foundation breadcrumb Component.
• If successful, you should see a breadcrumb trail , similar to the image below.
• A Cube Page has been ad ded below the Products Page merely for
example. Ad d your own pages bel ow the Products page and open them to
test the breadcrumb.
• In Design mode, feel free to modi fy the d epth at which the breadcrumb trail
begins.
• Default is leve l 2 (i.e . / content / trainingSite / en)
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.day.cQm
•
Co"gratulatio"s! You have successfully included the breadcrumb foun dation
Com ponent. Again, this is an exercise to get you familiar with not only the
process of inclu d ing a Component into a Template, but also to be more aware
of the plethora of Components CQ provi des out-o f-the - bo x.
Copyright 2010, Day Software AG , Switzerland Rev 1.5 20100907 www daYCQm
•
Extra Credit EXERCISE - Modify the Foundation
Breadcrumb component
Goal
The following exercise tests your knowledge of creating design elements. The
goal is to mod ify th e Fou ndation Breadcru m b compo nent so t hat an author with
de sign privileges can set t he value of the del imiter between t he crumbs. To
successfully com pl ete and understand these instru ctions, you wi ll need:
2. Use t he get of the absParent property as a gUide to get the delimiter from t he
currentStyle.
6. Examine the re pos itory to see the va lue s wr itten into the design when you
enter val ues into the design dialog bo x and save them .
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.day.com
•
Extra Credit EXERCISE - Modify your logo component
Goal
The followin g exercise tests your knowledge of creating desig n eleme nts. The
goa l is to modify your local logo com ponent so t hat the code uses content
entered by t he author into the existi ng abs Parent w idget of t he design dialog
box. To successfully complete and understand these instruct ions, you will
need:
2. Modify the logo component code so that it uses the absParent value to set
t he level for the link , instead of a hardcoded value .
4. Examine the repos itory to see the val ues written into the des ign when you
enter values into the design dialog box and save them.
Co"gratulatio"s! You have successfully mod ified your logo Component. Again, this
is an exercise to use your kn owledge of the currentStyle to extract design
elements and use them to render content objects.
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 wWW:daycom
•
Extra Credit EXERCISE - Modify your topnav
component
Goal
The following exercise tests your knowledge of creating design elements . The
goal is to mod ify your local topnav com po ne nt so that the code allows an
author with des ig n privileges to set th e root of th e navigation by entering a
path. To successfully complete and understand t hese instructions, you will
need:
Au thor / des igner can enter a path design element to set the root of the
top navigation list of pages.
Congratulations! You have successfully modified your top nav Component. Again,
t his is an exercise to use your k nowledge of t he currentStyle to set and extract
design elements and use them to render content objects.
Goal
The fo ll owing in structions explain how to include the foundation Component
the Paragraph System, w hich allows au t hors to dynamically manage a Page 's
content. To successfull y complete and understand these in structions, you will
need :
It allows content authors the ability to dynamically add, delete, move , copy, and
paste "parag raphs" on a Page, not to mention the ability to use t he column
contro l Component to structure your conte nt in columns. In addit ion , you can
decide what "content" Com ponents are allowed to be used by specific instances
of the parsys. It is Day's STRONG o pinion t hat th e parsys should be used as
often as possible , t hus allowing f or mere sim ple Component configuration as
op posed to creating a larg e number of Templates that developers then have to
maintain.
ccntcr.jsp
<%@include file: "/libs/foundation /q loba l .jsp M% >
<div class="center ">
<cq:include path:"trail" resourceType"'''foundation / components !
breadcrumb" />
<cq:include path-"t i tle" resQurceType"'''trai ning /components/contentl
title " />
<cq : include path- "par" resourceType .. "foundation/components/parsys" />
<idiv>
NOTE
As a lways, it is a good idea to review w hat you have just included . Take note of the fact this
Component only contains a Design Dialog (Le. design_dialog), thus can on ly be modified in
Design mode.
2. Test your script by req uesting a Page in CQ5 Siteadmi n that implements this
fou ndation paragraph system Com ponent.
• If succe ssful . you should see the parag raph system enabled, sim ilar to the
image bel ow
#
+"'
/
•
This is a custom TITLE to ... ii,
.,,-
1
/\
Yo u may have noticed earlier, afte r ass ig ni ng a new Design to yo ur Web site. that no
Components exist (are availa ble) in your Sidekick. This is because yo u have yet to declare, in
Des ig n mode, w hat Components are allowed to be used by a paragrapgh system . Only th en will
Components be mad e availab le in the Sidekick.
3. Se lect Pesig ~ ,"ode on yo ur Sidekick - then select "edif' for the paragraph
system Component to invo ke the Design Dialog .
4. Select t he Compone nts you wou ld like to allow for th is in stance of the
pa rag raph syst em - then select Oil..
•
P ar5ys (Desig n )
Arcros
Aklwed C ~ts
c"'"
[/ocumeotatlon Text
()ocumentatlOfllltle
, .,J _
~ ExterMi
<-I ""'"
, I lmaQf'
1 ' "'
~ Product lISt
.!- I Reference
l 5temap
I SlIde-mow
I hbl~
I Text
Text lrnoge
J Tide
'----'HoI.::!p'--JL_---',_..::OI~.b1 LI--=<an<=:c
d_
• If successful , you should see the paragraph system and popu lated Sidek ick,
simi lar to th e bel ow.
.
• _ _ WI ".
,
" " • (',
'-,
This is • custom nnE
.-. -.... I
~
""""
,-"
1_-
,-
..._-.,...--.......- ....-
4'
1<10 \
~-- ., ~./
Page preview of paragraph system
NOTE
Notice how Components now appea r in the Sidekick. These Components are now availab le to
use in the paragraph system you recently added to the Template.
le><l
~
,
~
Tr<l'- r
....1 1& /
__, r.!
Page preview of click and drag to paragraph system
World Standard Software to Unify Your Business 114
- ;:
rq • co
oJ _
,..
~ Pef,...ence ~i
I lt ·tI~
" .
r
?
". _.r ..........___ ...J" ..• "'~- .... -. ,, _.r."·--·-·" . . r" - / . ., _ - / ... ···'-1
Copyright 2010, Day SottwareAG , Switzerland Rev 1.5 20100907 www c/ay,Com
•
EXERCISE - Content Finder Drag-and-Drop
Goal
In this exercise we create simple Image component as an exam ple of a
com po nent that al lows drag-and-dro p of assets from the Content Finder onto
t he paragraph thumbn ail placeho lder. As a resul t of this exercise , you will feel
more confident buil ding a more co mp lex compone nt t hat rend ers bin ary data
and allows d rag-and-drop.
T o successfull y compl ete and unders t and these instruction s, you will need :
1. Right-click / apps/ < application name > / component / content - then select
New, Component.
2. Ente r the desired Compo nent '· Labe l", "Title", "Description" - then cl ick Fini sh.
• Label = mylmage
• Titl e = Training Image Component
• Description = Simple Im age Co mponent
• Group == Trai ning
• Supe r Resource Type = foundation / compone nt s/ parbase
• Allowed Parents = • !*parsys
myIm ~l ge.jsp
<'i@ p a ge impor t;"com . day.cq. wcm.foundation.lma ge" %>
<% @include file = "/libs / found at i on / global . jsp"%>
<,
Ima g e image'" new Ima g e( resource);
imag e . draw(out);
%><br >
1. Rig ht - click the dialog bo x f rom the f oundation Image component and select
copy.
~ L tfa n'"9
... L compon ents
... L content
New
lest
.. '-t.. undo
Copy :Jt: C
L.@ e{( n ....... Paste XV
Lt:I li bs (" 1 .. X Delete
Move ...
Rename ... F2
Import ...
ExoorL .
3 . Se lect Pesig~ mode by clicking on the ruler icon at the botto m of t he Sidekick.
Copyright 2010, Day SoftwareAG , Switzerland Rev 1.5 20100907 www daY·CQm
•
10. Drag an image onto the dialog box.
Defining editConfig
Now that we have our basic component wor king, let's add an editConfig to
allow drag-and-drop from the Content Fi nder.
PI "
Cr4>.:ut nC'''w nOM
2. Right - click the new cq:editConfig node and select New ... Node.
• Name : cq:dropTargets
• Type: nt:unstructured
• Name: imag e
• Type: cq :dropTarget Config
And then enter the g roups, accept, and propertyName properties as shown in
the diagram below:
"'- ~ - ...• , ..
• '- mylm.;J.; e
Y L _cq _e<l tContig
... k. _cQ..drop-argca , ,
-"ln1agt (cq:DropTargetConftg)
...... dlol ll)"g 0
L mylm.lgt.' JSP
' - testCOrT'pontrlt ••H,) rt
,. cc urdo
cv et(
L(j libs
~,}me Value
Properties groups
Info Jcr pflm01 ry"-ypc cq .DropT .l fg etCon"ig
.lccept Im age ! . •
Definition propertv'aM(' ./fil eRefere "c('
Cot1gratu lat io"s! You have successful ly created a Sim ple Image com ponent that
allows d rag -and - d ro p f rom th e Content Fi nd er. As an exercise, examine a few
of the other components in /libs / found ation / components t hat support d rag -
and-drop f rom the Con tent Finder. For exam p le, the Download. Slideshow, and
List components.
Copyright 2010, Day Sofrware AG, Switzerland Rev 1.5 20100907 www.ciay'cQm
•
EXERCISE - Create a Complex Component
Goal
The following instructions explain how to create a "complex" Component that
manages bot h textual and binary (i.e . image) content, and has both a Dialog
and Design Dialog. This includes allowing t he Component to be used by t he
parsys Component, creating a Dialog wit h mul ti pl e tab s, enab ling the
function ality offered by the Content Finder (i.e. drag-and -dro p), and other
configurations. To success fu lly complete and understand these instructions ,
you will need:
USER'S NEEDS: A Component that can be dropped into a paragraph system and
di splays an image , rich text, and the path of a Page in the system .
The image:
The image:
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www;davcom
•6. Test this Component by adding it to a Page to observe its output without any
written content.
7. Add a rich te xt Widget to the Dialog .
8. Add an image Wid get to t he Di alog.
9. Add a path co mpletion Widg et to the Desi gn Dia log .
10. Perform nece ssary Component con figuration s.
11. Test this Component by writing content using the newly created Dialog and
Design Dial og.
label: comolex
Title: Tralrung Complex Component
Oe<"..cnptlOl'l :
".
Super ResoLl"Ce Type : folt'ldatlon/component:>/parbo$E'
Group :
Mext Cancel
Not ice how the pointer on the image above is se lecting Next. This is ne cessary so that you ca n
decla re this Component has an allowed parent with the next dia log .
Container Settings
Enter- cont~ :iCttI'lQS fa the (OI'1Jxlnc"nl
AIowed Chikten:
Is Cont<tlfler rr
2. Ope n t he file co",plex.jsp, and enter some HTML and J5P code, simi lar to below
- then Save.
complcx.jsp
<%@include file=" / libs /foundation /g lobal.jsp" '>
<%@ page import:"com.day.cq.wcm.foundation.lmage" %>
<%
II getting the image from the Dialog/resQuce
1/ notice the use of the second parameter "image" - - this signifies that the
/1 image will live on a resource (called image) below the requested resource
Image image = new Image(resource, "image") ;
/ I setting the selector so that the "parbase" can work. its magic
image. setSelector ( " . img n ) ;
II getting the rich text from the Dialog
String text = properties .get( "text ... "TEXT NAn);
II getting the path from the Design Dialog
String path = currentStyle.get( "path", "PATH NA");
World Standard Software to Unify Your Suslness 124
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www: day.com
•
•>
<h2><%: path %></ h2 >
<%= text %>< br />
<.
image.draw(out);
.>
NOT E
For this exercise, do not concern yo urse lf g reatly with how t he content is d isplayed, as th is ca n
eas il y be altered via cod e cha nges and l or CSS.
• Yo u wi ll worry about Widgets and configurat ion s later - t he focu s now is to see
your new Component in action .
Edit Comp.;,or)!:!""'·
ParSys (DesIgn)
Notice how your complex Component is listed under the Training group . This is because you
declared such during the creation of your Component .
5. Test your script by add ing an instance of t his Component (i.e. paragraph) to
the paragraph system Component of a Training Page.
• If successful, you should see the default complex Com po nent, output, similar to
t he image below.
..,.,.,..".. (
PATH NA
·:>eneoal
ii _on)
/
TEXT WI .:, 1f 4lfW¥,lC~:( CompQ(lent r
\
,j
'-. '~.~ ,.--..#-, --."~ '~-,,. .....,...-... ..-.. . . .. . . ..... r"'" -'.1"',1-' "_ .. ,..~.r..' ..
7. Create a t ext node (nodeType cq :Widget) under the newly created items node.
g. Create an rtePlug i.s nod e (no deType nt:unstructured) under the newly create d
text node.
10. Create a table nod e (node Type nt:unstructured) under the newly created
rtePlugins nod e.
11. As sig n the features property (Type = String, Val ue = *) to the newly created
table nod e.
.-
"'>0
te ~t feat ... es
te! ,prIffKl! y t ~pe
"""""
':i:::=::.=J ...-/'
CRXDE retPlugin table plugin structure and property
12. Co py the nodes tab2 and tab3 under the node / libs/ foundation/
components/textimage/ dialog/ items - t hen paste to the co mplex Component's
Dialog so that they are a pee r of tab I (e.g. / apps / train ing / components /
content / co mplex / dialo g / items / item s).
Once again , it is often more efficient to copy-and - paste existing Dialogs / Widgets that meet
your need s. That being said , it is wise to review what you have just copied to better understand
the interna l workings of CQ.
If you ex amine closely enough . you will see the Widget is actually storing image related content
at a leve l deeper than current resou rce (e .g .. / image / file, ./ image / fil eRefere nce, etc.). This ties
nice ly w ith your previ ously written code (Im age image = new Image(resource, ~i mage ") ;) .
14. Create a pat h node (nodeType cq:Widget) under the newly created items
node.
15 . Assign the f ollow ing properties to the newl y created path node :
16. Copy the nod e /li bs / fou ndation / components/ textimage / cq :editConfig -
then paste to the root node of your complex Component (e.g. / apps / training /
com ponents / content / com plex).
• enab les d rag-and - d rop capabi litie s from the Content Finder
<path·ro-component>/ cq:editConfig/cq:dropTargets/image
• accept (Type = String) - the med ia type s to be accepted (e.g. image f."' , etc.)
• groups (Type = String) - t he groups in the Content Finder assets can be
ac ce pt ed from (e. g. med ia)
• propertyName (Type = String) - the property the refere nce shou ld be stored
(e .g . ./image / fi leRefe rence)
1 8. In the case w here the image is stored in a separate node (as is here) other
than the Component's primary resource , additional nodes and pro perties must
exist for d rag -and-dro p functio nality to wor k pro perly. In CRXDE navig ate to
<path·to·component>/cq:editConfig/cq:dropTargets/image/parameters
Copyright 2010. Day Software AG , Switzerland Rev 1.5 20100907 wwwda ycom
•
Set the sli"g:resourceType property so that your complex component is t he path to
find the rend ering script. For exampl e:
Set th e sli"g:resourceType prope rty so that the image component of your choice is
the path to find t he rend ering script. For example :
20. Test your script / Dialog by requesting a Page in CQS Siteadmin that
implements this Training complex Component - then interact with the Dialog
and Design Dialog.
• If successful . you should see Page output, a Dialog and Des ign Dialog similar to
the images below.
Copyright 201 0, Day Software AG, Switzerland Rev 1.5 20100907 www.dav:com
• Tab 1
B I U .- ,-,-
"_ c..-
.=-
- I~
- ~
--->1
'---_H_el'p- , - I_ _ -----'I LI _O~K,---~; I Ca"cel
Ref_ f""", •
Rotate
----=:01_->1 1 ("""el
Style- v
Descnpoon
Uri to
200 ox x
Title
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.daf.com
• x
( "'.
Design dia log of complex component - 3
Copyright 2010, Day Software AG , SWitzerland Rev 1.5 20100907 www·da v. com
•
COKgratulation, ! You have successfully created a complex Component that
contains a Dialog , Design Dialog , defau lt values, custom configuration, and
val idation of user input, in add ition to enab ling d rag-and-dro p fu nctionality
from the Content Finder. Give yoursel f a pat on the back - t his was quite a
ch all enge.
• cq :inpl aceEditing - this is where you allow content authors to have in- context-
ed it ing for textual content
• review j libs / foundation / components / text
• cq:listeners - this is where you can define actions (e .g. REFRESH_PAGE,
REFRESH_SELF, custom JS function, etc.) based on Component events (e.g.
afterinsert, afteredit. aftercopy, etc.)
• rev iew j libs / foundation j components / slideshow
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.day.com
•
EXERCISE - Include Multiple Foundation Components
Goal
Th e following instructions explain how to include multiple foundation
Components. This exercise is used to apply finishing touche s to t he look and
feel of the Training "Page" Component. To successfully complete and
und erstand t hese instructions, you will need:
1. Open the file body.jsp in the Training Contentpage Component and replace
t he "tool bar" < d iv> section with a < cq :include > of the foundation tool bar
Component - then Save.
• pat h = ';toolbar"
• resourceType = Hfoundation / components / toolbar"
2. In the Websites tab (S ite Admin Console), se lect the English page under
Training Site. Create the Tool bar page under English. Using the Page
Properties .. . in Sidekick set Hide in Navigation (in Sidekick) to prevent the
Toolbar page and all of its children from appearing in the Navigation
component .
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20 100907 WWW da llCOm
• When you load any of the pages in your website, the too lbar will look as
follows :
• Contacts. ~. bQgJn. ~
1. Insert a <cq :includ e> of the f oundation timing Com po nent directly above
the < I body> element in the fil e body.jsp - t hen Save.
The inherited paragraph system (ipars ys) is a parag raph system that also
allows you to in herit t he created parag rap hs f ro m t he parent page. You add
parag rap hs to iparsys at for example, / content/ trainingSite/ en .htm l and as
resul t , all t he su bpages of English that also have an iparsys with the same
name in herit the created paragraphs from t he English parent. On eac h level, you
can add more paragraphs, which are then in herited by t he children pages . You
can also cance l paragraph inheritance at a level at any time .
1. Open the f ile rig ht .jsp in t he Training Contentpage Component and re place
the "rig ht par" < div> section with a < cq :includ e> of the f oundation inherited
paragraph system (i.e. iparsys) Com ponent - then Save.
Copyright 2010 , Day Software AG, Switzerland Rev 1.5 20100907 www.dav.com
•
2. Test your script by requesting a Page in CQS Siteadmin that implements
these multiple foun dation Components.
• If successful , you should see a Page view similar to the image be low .
.•_ gecl"netnxx
..... __ b~
- '"
Page preview of completed page component
Copyright 2010, Day SoftwareAG, Switzerland Rev 1.5 20100907 www day.com
•
EXERCISE - Create a Search Component
Goal
The fo llowing instructions explain how to create a Component that will allow
visitors t o search t he content of t he Web site / repository. Th is search
Com po nent can be placed in the parsys of any Page, and has th e abi lit y to
search the content of th e We b site bas ed on a query string provided in the
request. To successfully complete and understand these instructions, you will
need:
1. An HTML form is needed to coll ect the user's input (search string).
2. Once the form has been submitted, you need to ca pture th e search string.
3. You need to prepare a que ry statement based on t he search string.
4. A q uery object needs to be created that will connect to the content repository,
and implement t he que ry stat ement.
5. You need to collect and parse the query results, if any.
6. Output related to the query results shoul d be displayed appropriately.
When q uerying a Java Content Repository UCR), some basic functiona lity (API
ca ll s) need t o b e implemented :
• javax .jcr.Session - JCR sess ion, can be reach ed for exa m p le by Node.getSessionO
• j avax.j cr.Workspace - JCR workspace , can be reac hed f or examp le by
Session.getWorkspaceO
For more detailed info rm ation , please review the Javadoc of the JCR and CRX
provided on the USB.
Group Tr.1,1,ng
"ext >
<~d
2. Open th e fi le search.jsp, and enter some HTML and JSP code, similar to below
- then Save.
• Notice how the Component will be fou nd in the 'Tra ining" group - this was
defined during t he creation of the Component
• If succes sful , you shou ld see the default complex Component output, similar to
the image below.
,
(
Customers f
Hello World !!! General
SeB.,ch
...:J Reference•;
,
~ Text / '
-',
-. . .. " ..,
' . ..... . , ....... . , ' . < .........
. ~
/14",
.'
6. Search for a word you know exists on a separate Page in your Training We b
site st ructure .
• If successf ul. you shou ld see search results output, similar to the image bel ow
• You may need to perform this search in Page preview mode, to ensure a "cl ean"
request
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 WWW.day.c om
•
Customers
Hello World! !!
• "
\"'/orks I Sear ch I
.
,.............. _.
Goal
T he fol lowing instructions explain how to ap ply CO's internationalization (i18n)
capabil ities in a Dialog. This wi ll allow you to provi de d ynamic Dial og
"messages" based on the authors' language preference. To successfully
com ple te and und erstand th ese instructions, you will need:
T he location of the i18n nod e w ithin t he reposito ry decides its scope . If located
in aproject directory (e.g . l apps / training), it shou ld contain only messages
re lated to th e current project. However, if located i n a Component hierarchy, it
sh ould contain on ly Component specific translations . Glo bally used messages
shoul d be place in / apps / i18n.
1. Create an il S" node (nodeType sling:Folder) under the root node of the title
Component.
3. Open a Content Ex plorer w indow and as sign the IMixi". mix: language to t he
new ly created en node
-, . ...J ' .. . •
. t. .
.· v.,"~
. ,) ....
- ,,; .,,,.
.,
.~
~-
~~
... -
-
".
' 0'
-
..,
~_!~{I""Ql:J... ' ~~ ""<1:0.00
· ..J _,'"
· ..J .--..oo;
..; ...
!<I .Io.....
' 0'
.....~-..,
M
· .J ~
'J ~
. ~-
· ,J ...--
·v _
• ,.J -
· ..Jtt~
· .t,Ne.;
· ..J:..
'<'
--
.~
-
• .J •
. .J.
. .;· .,-
· .J .~"''''''''
.".....
• ..J a:rI~
.. ~
:..-
~_!.oe
,"'. .,
,. ..
· ,; _ .... ,,- !.",
· ,j .- :..~........o.. "...
- ..J ....w
· J ... ... ........X1f ..... J .....-
.
•
., ~
choose mixin
''lice :)r(:lJ e
t!l m-x:crea~
m,,:e2g
~ m )( .'.!'w;~~
m l<, '!.!stMOO-f.ec
m d fccvoe
: ' } m ~ .foco(,,!:lle
m.;c:rn :nety::le
•
:: ~ m ..-refe-er'lCei!:l e •
• the property that identi f ies the language using the ISO langu age code
• Name = j cr: language
• Type = Strin g
• Va lue = en
-·
-..(! • ..."
.-..-
· -'"
<~ ••
• to· .
"
,.~" .....
, "
""-' ... - .. __ c~_
,.,
A . . . ' · .......
•.- ... _.... --...
.,. .. -
....
,..
"I .. '
'..
.....
',.
',.
,. ',
6. Create a fieldLabel node (nodeType sling :Message En try) under the newly
created en nod e.
7 . . Ass ign the following properties to the newly created fieldLabel node:
8. Change the fieldLabel property (Value = i18n-tit le) on the title Component's
Dialog title node.
• If succes sful, yo u should see Dialog output similar to the image below.
,... ,
r:[!:I~'~3~.f~'~"~!1~u~"i~I~II~i:========
-Enta
shiel Title Hell'! (1
- 1Bn ~
Copyright 201 D, Day Software AG, Switzerland Rev 1.5 20100907 www.day'CQro
•
Co"gratulatio"s! You have successful ly applied an i18n message to the title
Com pon en t' s Di alog . Since th e content author's def ault / current language
preference is Eng lish , t he en message you defined earlie r sho uld appear. If you
were to add an additional i18n message , for exampl e in French , and then
changed th e content author's lang uage p refe re nce to fr, t he French message
you define f or t he i18n- title key should appear. It might be of best interest to
you to try th is now.
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www·dav-cQm
•
EXERCISE - Create & Register a Widget
Goal
The following instructions explain how to create and register a CQ Widget. This
wil l allow you to apply custom Wi dgets to your Dialogs and Design Di alogs . To
successfully co mplete and understand these in structions , you will need:
• Create a J5 library
• Extend an exist ing xtype /Widget
• Register the new xtype / Widget
• Use t he xtype / Wi dget in a Dialog
3. Create a files node (nodeType sling:Folder) under the newly created training-
widgets.js nod e.
Before you can use any custom xtypes / Wid gets , you must first regist er t he
li brary in which they exist, which occurs during the WCM in itialization process
(i.e. init.jspl. T o register your JS library you will need to mod ify the /li bs / wcm /
core / component s / init/ init.jsp. Si nce mod ifying anything under / Iibs is strongl y
not recommended, you will need to create a copy of the original init.jsp f or your
custom project / mod ification. In ad dition, si nce yo u wil l be usi ng a custom
init.jsp, you will need t o mod ify t he head.jsp that references the init.jsp. The
head.jsp is associated with the "page" Component you created earlier.
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 wwW;daY-com
•
1 .Co py t he file /Iibs/wcm/core/components/init/init.jsp. Paste init.jsp into
the /apps/<application name>/globa l folder.
3. Open the file i.it.jsp, and enter some HTML and JSP code, similar to below -
then Save.
init.jsp
<\@inc lude file;" t Ubs / foundation / global. jsp ft \ >< %
\> < \ @page import="com . day.cq.wcm.api . wCMHode,
com.day.cq . widget . HtmlLibraryHanager" %>< %
if (WCMMode.frOmRequest(request) 1= WCMMode . DISABLED) {
HtmlLibraryManager htmlMgr = sling . getService(HtmlLibraryManager.clasS)i
if (htmlMgr != nUll) {
htmIMgr.writeCsslnc!ude(slingRequest. out, "cq .wcm.edit " );
out.flush();
htmIHgr . writeJSlnclude(slingRequest, out , Rcq.wcm.edit~.
Mtraining.widgets " );
}
String dIg Path % null;
if (editContext != null && editContext.getComponent() != nUll) {
dlgPath a editContext.getComponent().getDialogPath();
.>
<script type-="text / javascript" >
var fct - function() {
CQ.wCH.launchSidekick( "<%IE currentPage.getPath() %> ", {
propsDialog: "<%= dlgpath == null? "" : dlgPath %>",
locked: <%= currentPage.isLoCked() %>
}I;
};
window.setTimeout(fct, 1);
</script>< %
.>
5. Open the fi le head.jsp, and enter some HTML and J5P code, similar to be low -
t he Save.
Finally, we will create a new xtype / Wid get by extending an ex isting xtype/
Widget. Ext.J5 is a large, powerful, and somewhat compl icated J5 framework. If
po ssible , it may benefit you to attend Ext.J 5 training .
Copyright 2010, Day Software AG , Switzerland Rev 1.5 20100907 WWW.da llcom
•
How to create a~d test a custOIll xtype/Widget:
File
Create 6 new file l esource.
• geometnxx[nt :folder]
trainlng[nt:folder ]
• -.l components[nt:foldpr ]
docroot[nt:folder]
_ global[nt:folder]
~ r"stall[nt:folder]
- src[nt:folder]
+ ...: ternplates[nt :folder]
- tr dinIng-widgets. JS[cQ:ClientlibraryFolder]
frles[sling:Folder ]
• , etc[shng:Folder]
I Finrsh ~II
u
Cancel I
CRXDE new file dialog
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 WwwdaYCQm
•
2. Open the file tral"l"g.js, and enter some JS code, similar to below - then Save.
) );
CQ.Ext.reg("trainingSelection", Training . Selection);
3. Create a trai"i"g node (nod eType cq:Widget) under the Training title
Component's Dialog cab 1 widget collection.
• e.g. / apps / training /components / content / tit le! dialog / items / items / tab 1 / items
• If succes sful, you should see t he custom Dialog xtype, similar to the image
below.
Ta b I
Trdlning Selecton
WO;Jet ~~------------~1
8 :00 At"
6
...
8: 15 AM
8 :30 AM
8 :45 AM
9 :00 A/'-1
9:15 AM
9 :30 AM
9:-45 A",'
10:00 AM
10 : 15 AfJ!
10 :30 AM
10:45 AM
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.day.com
•
Co"gratulatio"s! You have successfully created and applied a custom xtype /
Wid get. This is a significant step in your development capabilities, as you are
now able to create custom CQ xtypes / Widgets . To f ully com plete th is exercise,
you would output / use the user's selection in manner deemed appropriate.
Goal
The following instructions explain how to create and consume an OSGi Bundle.
T his will allow you to create and use custom Java classes in your J5P scripts,
allowing for more traditional Java development and library reuse . To
success ful ly com pl ete and u nderstand these instructions, you will need :
An OSGi fra mework then offers you dynamic loading / unload ing , configuration
and control of these bundles - without requiring restarts .
This a rc hitecture a llows you to extend Sli ng with ap plication specific modules.
Sling, and t herefore CQS, uses the Apache Fe lix implementation of OSGi an d is
based on t he OSGi Service Platform Rel ease 4 Version 4. 2 Specifications . They
are both collections of OSGi bundles r unning within an OSG i framework .
Copyright 2010, Day Softw are AG , Switzerland Rev 1.5 20100907 www.dav.com
•
This enables you to perform the following actions on any of the packages within
your installation :
• install
• start
• sto p
• upd ate
• unin stall
• see the current status
• access more detailed information (e.g. symbolic name. version, location, etc)
about the specific bundles
1. Se lect and rig ht-cl ick the Training projects OSGi bundle source directory
(i.e. / apps / training / src) - t hen select Juild .. Create Ju.dle.
.. I.: Ira n r.1I
N,w ,
Copy xc
JC Delete
Move...
Rename ...
.. ,
".. CteaIt au L.
,- Properties
Create Project ...
,
JO ('U lt"
jel c'ulea!y Compile
Inlo Vl.':rsion Control
Ie. ,,, ,..,.yl'lType
Refresh Classpalh
3. Open the newly created bund le's f ile org.training .test.Te stBundle.bn d - verify
that the te xt - SNAPSHOT has been added to the Bundle-Version.
• this ensures the bundle is automatical ly in stalle d and started in the OSGI
container every ti me the bundle is built
Export - package : *
Impor t - package : *
Private - packa ge : *
# I nc lude- Resource :
Bu ndle - Name: Test Bund l e
Bundle - Descriptio n: NA
Bund le - symbolicName: o r g . traini ng .tes t . TestBundle
Bundle- Ver sion : I . D. O- SNAPSHOT
Bundle-Activ ator : org.trai ning.te st.Activator
Copyright 2010, Day Software AG . Switzerland Rev 1.5 20100907 WWW:day. com
•
NOTE
• The node org .training.test.TestBundle of type nt:folder - it is the bundle container node
• The file org .tra inin g.test.Tes tBundl e.bnd - it acts as deployment descriptor fo r your
bundle and consists of a set of headers
• The folder structures :
• src / main Ijava / org / training / test - it will contain the packages and the Java
classes
• srcj main / resources - it will contain th e resources used wit hi n the bund le
• The Activator.j ava f ile - it is the opti onal listener class to be notifi ed of bundle start and
stop events
4. Create a new Java class in the newly created bundle source directory (i.e. src l
-
mai n /java l org I trai n i ng Itest) .
."'.
..,
01'9 tflWWlQ.test. T~
.
"'
,.......,
Itt Actrvata,
i " ..
, ~,
-..
Set P.,ru.)' l~
Jav a Class
Create a new Java ellis.
Hellowor!i
....'
11 absb act 0 lIMI
Cancel
6. Open the newly create d Java class file HelloWorld.java, and enter some Java
co de, simi lar to below - t hen Save.
World Standard Software to Unify Your Business 161
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.dar.com
•
package org.training . test;
publ ic class Hell oWor ld {
public String getMessage ()
return ~Hel lo World !!! ";
7. Select and right - click the Hel/oWorld.jQ\lQ file - then se lect &uild .. COlllpile .
.. '- ,-<
.. _- 'U'
'_-0'0
"'. '
.,,- 'u.
. N~
0,,,
•
......10< •••• Open With •
_ ,""""«u Copy XC
0<0.1t. ~ ..., ' U f lfl'l'~rl'''' _ ''''d
...... ••
"'~t
)( OtJ~lt ®
.~
••• M(M! .. .
Re namt ...
Imaort Di rtClory ...
"
0<.
II Impo rt F.lt ...
.~ A",,, "<"00 ....
,c. <, •• te<l
,., , -•• mla,
jcr p· ........ roo
•
•
UI)Ort ...
"J' ..
,oj
1;>1
Rtfruh
" CrUll! ProlK I ..•
"uslan Control •
C RXDE compile Java class
•
1'; Compilation completed succes:;fully
OK ..t
' - - - - II.;,
ActivatOr.}dva
HeIloWOlId .Ja...·a
Ched<.out
Commit
Update
St~ us
{,
+ templates
_.... , ...... -*' ....... .td!q.'N-.w!dgets..}5.... ,~..,.., 1: '-, '...,.. • .... ft ·. ..,... .....,
..............,- ......
. . -.....
~-""
... ~. p.~r
'.
CRXDE bui ld bundle
. , .
.
1,J Build completed successfully
OK
Copyright 2010, Day Software AG . Switzerland Rev 1,5 20100907 WWW.da y.com
•
9 . Open the Training title Component's title.jsp, and enter some HTML and JSP
code, similar to be low - then Save .
title.jsp
< %@include file:" / libs/foundation / g!obal . jsp "%>
<l@ page import- "org.training . test.HelloMOrld " %>
<hl><i - properties.get("title", CULLentpage.getTitle(» I >< / h l >
<,
HelloWorld hw - new HelloWorld();
,>
<h3><1= hw . getHessage() %></ h3>
10. Test your bundle/ script by requesting a Page in CQ5 Siteadmin that
implements this Training bundl e (i.e. t he t itle Com po nent).
• If succe ss ful, you should see the ti tle Com po nent output, si mil ar to the image
below.
...
. '" CUSTOMERS • '.
geomeulXX
• sh:.pes tor cefltl.n"s
This is a custom TITLE
Hello World !!! r
This . sure hope it 'NOrks I! I
t
•
/ content/training/ en / company .'
<
Copyright 2010, Day Software AG , Switzerland Rev 1.5 20100907 WWW.daV CQrn
•
Co"gratulatio"s! You have successfully created an OSGi bundle, and have
consu med t he associated Java class. Once again , t his is a significant step in
your develo pment capabilities, as you are now able put more "heavy logic" type
of co de into Java classes, where it belongs, in addition to be ing able to create
Java helper classes that can be re-us ed by your development team.
Goal
CQS encompasses several applications that are designed to interact and
complement each other. In particular, the Workflow Engine can be used in tight
conjunction with several of the other applications.
For example, within CQS, Web Content Management (CQ WCM) is key. This
enab les you to generate and publish pages to your website. This functionality is
often subject to organizational processes, including steps such as approval and
sign-off by various participants . These processes can be represented as
workflows, which in turn can be defined within CQ, then applied to the
appropriate content pages .
The following instructions will increase familiarity with the Workflow Console
and working with Workflows. To succe ss ful ly complete and understand these
instructions , you w ill need :
Workflow models are versioned. Running Workflow Instances keep the initial
workflow model version that is set when the workflow is started.
Step
There are d ifferent types of workflow steps :
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www·dav;com
• Container (Sub Workflow)
OR Split /Join
AND Split /Join
All the steps share the following common properties : AutoAdva"c. and nlll.out
alerts (scriptable) .
Transition
Defines the link between two consecutive steps. It is possible to apply rules to
the Transition.
Workltem
The workltem is the "there is a task identifier" and is put into the respective
inbox . A workflow instance can have one or many Workltems at the same time
(depending on the workflow model).
Payload
References the resource that has to be advanced through a workflow.
lifecycle
Is created when starting a new workflow (by choosing the respective workflow
model and defining the payload) and ends when the end node is processed.
Terminate
Suspend
Resume
Restart
Completed and terminated instances are archived.
Workflow Console
The Workflow console is the centralized location for workflow management in
CQ. It can be accessed via the Workflows button on the We lcome page or
through the Workflows button in the tool bar on any CQS console (for example:
Websites, Tools, T agging).
Models
Lists the workflow mode ls currently available. Here you can create, edit or
delete workflow models .
Instances
Shows you details of workflow instances wh ich are currently active . These
instances are also ve rsion dependent.
Archive
Enables you to access detai ls of workflow instances which have terminated, for
whatever reason.
launcher
Allows you to define a workflow to be launched if a specific node has been
updated.
Starting a Workflow
There are three methods of starting a workflow:
. Workflow Console
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.da y. com
• . Sidekick
NOTE
T he current version of the wo rkflow mode l is assigned to the payload ; if the main copy of
the workflow is updated later, the changes will have no impact on the currently run ning
instance.
1. Open the SiteAdmin console, ei ther by clicking on the Websites button from
the Welcome page or by clicking on the globe icon at the bottom of your
sidekick.
•
-- ----- ...
CQ5WCM
_._. _ JlII<
" ~
~-
"~
-~
- -
"I~.
.. ·l "", .. .......
, ~-
=lll ~" ... Do ...
:.Iii &9....
s.o.
, ~
-"il "._ ~
~,n,,"--,
"J!J l>ot1\oI
~ :U _
..
---
"~ B~
~ ... ::.
. ~
JiI """"'s...
"~
ii"'--
,, ~
,,- 'tl~
3. Select the Publish Exalllple workflow and fill in any desired optional information
and cl ick Start.
--
. -~ ____ . _ J_.
·, ..-t_
_.- -- -
'- - - ----
---
...... '-
'--- , " _ t ; . . - ..
'.-
~
.. ..
•r ••
-
· ....-"'""--
,-~
. ~-
.-
.-
.-
5. Change to the Workflow Console by clicking on the workflow button in the
tool bar. Select the Models tab. Open the Publish £Xa",ple workflow by double-
clicking the workflow model entry .
•
-.-
-
. ...,. .......... -- .. - .......,..---
~
---
. ..... •..
. ~
Cl iioll
. _ . . ..<0 _ _ _ _ ,
- --
r.......' _
.--
---- ••
""'_.-"'--
You will notice that the Publish £X."'ple workflow has 2 steps : ValidateCo"te"t
and Publish Co.te"t.
The Validate Co.te.t step is a Participant step assigned to the use r admin. The
PublishCo.te.t step is a Process step with the Implementation Property set to
ActivatePageProcess .
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.day.cQm
• You can validate the values of the step properties by clicking on the cog in
the step and then inspecting the values from the properties list on the right.
• .,
-- -
CQ5 WORi'\F"
--
.. N
- .......
- ......-
--_
•
,.
---,-- _-_- ,~
.....
· .--
;
~.
~
p ...... - - . . .
~~,
-~,
- ....
"' ....
,- -
'- ~
. -~
"-1"0 _ _ .-
I.:;·
,~
-"' .. --
".~ c..-
...
T>oe _ _ ", ... _
6. Click on the I~box tab to change context. The Inbox will show the Workltem
entry for the page you put into workflow.
• . ,
- _ c...-.. _ _ T."._ _
_ .... -<-<
,
'*
~...... ~ ............... ,...- .t-looO-le:o " .i l ~.'•••~••••"""'""""
7. Select the Workltem Validate Co~te"t and click COlllplete. Notice that the
Workltem disappears from the Inbox. You will also note that the page is now
no longer in workflow (the workflow icon is gone from the status column)
and the page has been published or is pending publication (depending on
whether you have a CQS Publish instance running).
Copyright 2010, Day SoftwareAG , Switzerland Rev 1.5 20100907 www: day:com
•. -
•
- -
_ _ ., _._ . _ J_'
<
....
..
-
.. ~ Cioor'c!:'..,~s...
•
~""'"'"""'-
\04. CooWn!
,,--
,~
.,-
-,,~--$ ..
..t:!..l~
COI'Igratuiatiol'ls! You have learned about the Workflow Console. Also, you have
successfu lly placed a page in workflow and moved that page through the
workflow steps to the the end of the workflow. In the next exercise, you will
use this knowledge to help you create a custom process step and define a
workflow to use that custom process step.
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 wwwctay.CQm
•
EXERCISE - Create a Workflow Implementation Step
Goal
A workflow is made of steps. The steps that define a workflow are either
participant steps or process steps. Participant steps require manual intervention
by a person to advance the workflow. Process steps, on the other hand, are
automatic actions that are executed by the system if certain specified
conditions are met.
Process steps, also called automated steps, can be defined by using either
an ECMA script or a service (a java class in a bundle) . Services can be deve loped
to listen to special workflow events and perform tasks according to the
business logic.
The foll owing instructions explain how to create a workflow custom process
step using a j ava class. To successfully complete and understand these
instructions , you wi ll need:
1. Create the bundle to hold the java class using Jvlld ..Create JVKdle.
•
Copy xc
X Cklete
MOlle •.•
Re name
Import Dm!ctoIV...
"
Import File ..
Export ...
~t Primary Tvpe
~ Refresh
"
Create ProJect•.
Propeni ~
CamptiI'
Version Control • Rl'fresh Classpath
Crutt BLind Ie
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 WWWdatl;com
•
I"
J;avlo ct.us
Cre,lt" ~ ~~ ).lv~ cl~n
If.,.. .....
AG4 ••
3. Open the new ly created Java class file MyProcess.java, and enter some Java
code, similar to below - t he n Save.
import org.slf4j.Logger;
import org.slf4j.LoggerFactorYi
import com.day.cq.workflow.Workflowsessionj
import com.day.cq.workflow.exec.JavaprocessExt;
import com.day.cq.workflow.exec.WorkItem;
import com.day.cq.workflow.exec.WorkflowData;
import javax.jcr.Node;
/ .. * uefault log . * 1
protected final Logger log = LoggerFactor y.getLogger(Myprocess.c lasS)i
NOTE
Pay special attention to the @scr.componenr metatype=''false'' and @scr.service comments.
These two lines are required to ensure that the implementation step appears in the list of
implementations.
NOTE
The java methods, respectively the classes that implement the executable Java
method are registered as OSCI services, enabling you to add methods at
anytime during runtime.
Copyright 2010, Day Software AG, Switzer1and Rev 1.5 20100907 www.dav.com
•
5. Build the Bundle using Juild ..Juild Ju"dle. Once you get the "Build Successful"
message, you will notice that the bundle .jar file shows up in the install
directory. The bundle is now uploaded and installed into CQ.
CO"Qratolatio"s! You have created a new Java class that can be used as a custom
Implementation in a Process step.
1. Navigate to the Workflow panel. Choose the Models tab. Create a workflow
by choosing New from the tool bar. Enter Approval as the Title of the
workflow .
• .
- -- --
CQ6 WORKFLOW .., ... -.;
1 DoO.I1_~"_
-- - '"
• fW1 Ddeu: __
, [),I.M s.._~...,.,
,
I.
:l
:1
OUII'*ate_, c- C~_"
OUII"IXlate ,_
[),I.M~_
' ......
lIi'>_
c..... _ J. -
•
-
[),I.M Jpcj .\I: !rOm
:l _ r.... ... pIto
\~ P>..I>Isn E.i.>.rpl<
:5 ~IO'.o.;,...""" ,~
·7 ~to.o...e_
_ _ _ _ _ ....
OK I. er- J ...,.
'"
2. Open the Approval workflow by double-clicking on the Name .
Copyright 2010. Day SoftwareAG , Switzerland Rev 1.5 20100907 WWW;daY- com
•
3. You will notice that the new Approval workflow model has a Start, End and
Step 1.
•
··-.......
- - -
---.- - -
~_"~l
[,.,;aj r>!%?.:;r..". ,-
o
r... ..., ~
,-, ~
'_'iO<'I<l""
<& ~:
h~ "W\<:,Qoo<'t
u,..."-c.",,, K,.
_.
... " -
"
~ .
o.sa""....
U-... i ." 01/;<,0:.00.
~~
_l<!~d~
.~
fo<1"I ".:11
T,,,,,,,,,,! ~
- o.ur.t - . • )(
T....... ~tl'lln<:!e<
~I G":'.. f>
-
Pa--tit.-L
•
- ..
CQSWORI<F...OW .., '"""
--.--
, ....... _",""'- ,
-
. .-- -~
"""
. '-"-- .,
...
6. Set the properties of your new Process step :
• Description = Set "approved" property
• Implementation = MyProce ss
• Tit le = Fi nal Ap proval
• Pro cess Argument s = true
---,-- -
• -====-=-=~,~-
-.--
-,-- - -~
.
--
.......... _11 _ _
~.
---
--~ _.-
-~- §f'"
.--
T*
- - 0 r _
~--
§?=[
---
.... _ _<il ... _
---- ~
.CJ
.... _ . ._ :
Click Save.
7. Test your new workflow. In the WebSites panel. select any page. Bring up
the right context menu and choose Workflow ... Select the new Approval
workflow and click Start.
8. Monitor the progress of your workflow from the inbox and move the page
through the workflow. Check for the approved property on the page once
the workflow has completed .
01;'-"
................ ...,..--...-
tJ i I -·· ., . •
.--
"" ,-
~
. J~
• .,J ....
-----
. . . J _.
. .....,-
_.
.~
- !.on_ •.:."=
:::-:..-=:-:::.-:.....---'~::'''------.: . ~-.---
.
... -
. ,e"._
.,, ~
c- - . ::>
- -
.... _"" .......
Copyright 2010, Day $oftwareAG, Switzerland Rev 1.5 20100907 WWWdaY. Com
•
EXERCISE - Create & Download a CO Package
Goal
The following in structions explain how to create a CQ package that will
combine all elements of t he Training project, minus al l jpegs. This is a good
ex ample of packag ing application content, which you could t hen distribute to
team me m be rs for review. To successfully complete and understand these
instructions, you will need:
Ad ditionally, it contains vau lt meta information, includ ing a filter definition , and
import configuration information. Add itional content pro perties can be included
in the package, such as a description . a visu al image , or an icon. T hese
pro perties are for the content package consumer for informational purposes
only.
In this exercise, we will be using the CQ Package Manager. You should take some time
to explore the documentation for the CRX and cURL methods of managing package s.
How to create, build, a~d dow~load a CQ package i~ the "fools" sectio~ of CQ5:
• CQSWCM ... -.
< !.l New.. Copy
~
........
J l ooIs
~
"'-
~ '!'!- (ust(lffl Ooo:~¥.oOn
~ f(O' m SWmlSSIOOS
;l;) _ Impotter~
....J ExternailinWle.:1ef
_ New*tte.
" p" , , -
ntle
6 . Enter the package "Group Name" (trai ning) and "Package Name" (training-
project).
traiTlQ
• CQ6 W(:.M
'.
J . . Fe r.oetnwn ,
9. Enter the "ltootPath" (l ap ps / training) and a "ltule" that excludes all jpegs
(Exclude ~ > .+ \ .j pg) - t hen se lect OK.
~.,
'-..
• CQ5
,
•..
training-project
t
Edit Preview Bu~b ...
•• ~~.
•••
4pp:vtr4'n'n~ tl a''''''g-v , dgets ,S
app~ u a ln'''~ trall""';I-v,d';lets )S
' apps l ..HnUt<) 'r••
n'''9-",d';let 5 )$ f. l~
•• /apps ' tr~'nlng / tralnln';l_v ,dg el s ] s/ II I~ a:lnte" t x.1
/app s·· traln'D9 ~ tr•• n'n'i'l-v,dget" ]"/ l l le,, tr ..... n''''3 ,.
Copyright 2010, Day SottwareAG, Switzerland Rev 1.5 20100907 Www·daY- com
•
e - CQ5 ~
/
,
training-project
;
i
.-
,/
,, /
. .;' -)
Package build information
Congratulat ion,! You have successfu lly created a package, added a rul e to the
f ilte r definition, bu ilt t he package, and have downl oaded the pac kage, which
you can now share with your CQ development team.
Goal
T he f ollowing instructions ex plain how to monitor Page response times, in
addition to finding slow Page responses. This will allow you to create a more
ro bust / scalable CQ application , even with limited hardware. To successfully
com ple te and understand these instructions, you wil l need:
The response times yo u will be aiming for will be different on the author and
publi sh environments , reflecting the d ifferent characteris t ics of the target
audi ence :
Au t hor Environment
This environment contains content which you make available to your users,
w here t he nu m ber of requests is even g reater and the speed is just as vital , but
since t he nature of t he request s is less dynamic, additional performance
enhanci ng mechanisms can be leverage d. such as t hat the content is cached
or load- balancing is ap plied.
Copyright 2010. Day SoftwareAG . Switzerland Rev 1.5 20100907 Www. da y:cqm
•
Performance Opt imization Methodology
Around 10% of the project effort should be planned f o r the perfo rmance
optimization phase. Of course, the actual performan ce optimization
req uirements wi ll de pend on the level of co m plexity of a project and the
experience of the deve lopment team . Wh ile your project may ulti mately not
req uire all of the allocated time, it is good practi ce to al ways plan fo r
performance optimization in that sugg ested range .
Wh enever poss ible, a proj ect sho uld f irst be so ft - launc hed to a limited
aud ience in order t o gathe r real - life experience and perform f urther
optimizations, without the additional pressure that fo llows a f ull
announcement.
Once you are "live", pe rformance optimization is not over. This is t he point in
time when you experience t he "rea l'· load on your syste m . It is important to plan
for ad ditio nal adj ustments after the launch.
Since your system load changes and the pe rformance profiles of your system
shifts over time, a pe rform ance "tune-up" or "health-check" should be
scheduled at 6-12 months intervals .
Simulate Reality
If you go live with a Web site and you find out after the launch that you run into
performance issues t here is onl y one reason for t hat: Yo ur load and
performance tests did not simulate reality cl ose enoug h.
Simulating reality is difficult and how much effort you will reasonably want to
invest into getting "real" depends on th e nature of your project. "Real" means
World Standard Software to Unify Your Business 188
Establis hing good , solid performance goals is really one of the trickiest areas. It
is often best to collect real life logs and benchmarks from a comparable Web
site (fo r example the new Web site's predecessor).
Stay Re levant
This largely means that the developer im plementing the optimization should
have a quick way to tell if the o ptimization has already reached t he goal, which
is va luable infor mation, because when the goal is reach ed , optimization is over.
Generally speaking, keep your uncached html req uests to less than
lOOms . More speci f ically, t he fo llowing may serve as a guide line :
Copyright 2010. Day Software AG . Switzerland Rev 1.5 20100907 WWWdaY: CQm
• •
•
70% of the requests for pages should be respond ed to in less than lOOms.
25 96 of the requests for pages should get a respo nse within 100ms- 300ms.
• 4% of the requests for page s should get a response within 300ms - SOOms.
• 1% of the requests for pages shou ld get a response within 500ms - 1ODOms.
• No pages shou ld resp ond slower than 1 second.
Th e above num bers assume th e f ollowing conditions :
Your best friends during a usual performance optimization exercise are the
request .log, compo nent based timing, and last but not least - aJava profiler.
2. Request a Page in author that utillizes your Train ing Template and
Com ponents.
3. Review the response times directly related to the previous step's request.
NOTE
Though this is clearly the response time of a Page whi le in author, it Is good practice to be able
to identify where response times are located (request. log) and how to identify a specific Page
request / response in the log f ile itself. Ideally, this test would occur on the publish instance to
get a better idea of its expected behavior in production .
3. Navig ate to and select the "Timing chart URL" located in the HTML source.
• You will find t his URL most likely near the bottom of the HTML source, as it is
generated by the foundation timing Component
, di'" c1a •• -" I: 0 0 lb!5.[" " >< SC' Ti I)l type -" t ey.c / J e;', -3.!l C r 1 pt " >
CQ . !JC M. e dl.'t ( t " path": .. / c o n c .... nt.i t-ral n lng! en/compa.n y/ )el: : CO nte fi C/ t o o l b a r" I " t.y p e
</ scrillt ':>
</ 1111.' ;"
<th'" c1.a.5 · "d l ;'SC 1~ lme r "> cti !lc lallr~r <./ III v >
<! dl- v;,
(
</ h od:,/> t )
,.
• f'
J
<I"
-!
,\
#
• I
.,•
~
I ,.
("
• <-
C
~
.;;;
NOTE
The light blue color id ent ifies when the Component /JSP started . The dark blue color identifies
how long the Component /JSP took to respond .
Copyright 2010 , Day SoftwareAG , Switzerland Rev 1.5 20 100907 wtyW dalt com
•
Congratulations! You have successfully monitored Com ponent based ti m ing using
t he f ou nd ation timing Compo nent. Again, this wi ll aid your deve lopment in
being able t o monitor t he response ti mes of specific Components wit hin t he
context of an actual Page/ Template request. Next, we will focus on how to find
long lasting req uest / res pons e pairs.
2. Enter the command java -jarrlog.jar in your command line to get help
concerning poss ible arguments.
El DOS
Info M Par~cd 2136~ pequests .
Info * Ti~e fop parsing : 281~
Info • Ifllle fol" sorting: 161115
Info • Total Melllory: 2211lb
Info • Free "enory: Ynb
Info • Used MeAOry: 12Ab
4418?n$ 23/Dec/2009:10:36:55 -0590 209 GET /etc/reports/diskus&ge.htPlI text
Iltl'll
327811'1s 22/Dec/2009: 10: 36 :21 -0509 2 •• GET /bin/crxde.classpath.XAl text/lUI.
1
J€l094111s 05/Jan/2010:09:40:S1 -0501.1 200 GET /bin/crxde.c lasspath.xnl text/xIII
1
25625J1ls 13/Jan/2010:14:S6:47 -0500 280 GET /ctc/reports/diskusage.htllli text
htl'lll
21281ps 08/Jan/2010:09:11:S4 -0500 2 •• GET /bin/crxde.classpath.xnl text/xJI1
1
21312J1ls 06/Jan/2010:16:04:3? -0508 2 •• GET /bin/crxde.cla~spath.xRI tcxt/XJll
1
19985J1ls 18/Jan/2010:B9 : 50:44 -0500 2 •• GET /bin/crxde.classpath.xRI text/xJll
1
19968Pls 06/Jan/2010:10:59:32 -0500 2"" GET /bin/crxde . c la!l~path . Xl'll text/xl'!
1
196851'ls 28/Dec/2009:10:28:29 -0500 2"" GH /bin/crxde . c la~spath. Xl'll text/xl'!
1
1'1594111s 11/Jan/2010:10:Z3:4J - 0500 2 •• GET /bin/crxde . classpath.xl'll text/xJll
1
: 'ddY'aut hor'crx-qu ic kstart ~pt'he Ipers >
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www clav.com
•
NOTE
Essentially, the rlog.jar tool is parsing the request.log to find and display the 10 longest
requests / responses. You can use this information to further investigate what may be the cause
of the long response .
Co"gratulatio"s! You have successfull y found and displayed long lasting requests /
responses in CO. Again, this is just one of many tools to hel p you meet your
proj ect's performance goals. Finally. we will view t iming statistics for Page
rend eri ng .
1. Req uest a Page in CQ5 Siteadmin that implements your Training Temp late
and Components.
, ..
I
10.d "'t.ati(;"tic~:
'" '"
~, building edi.t in9'''
:rt .at'!;:
I
'" Complete docWflent lo.aded
~,
,as
~ / ~, Completed I: ",no.., I' ing l:011ovez:
/ St.az:t: :u ,ndoering z:olloVCII:
'" m,
~,
~ I
'" m,
,n
I
Completed renderi.ng J: olloveJ:
St.art xcnde II: i.ng tollovel:
". m,m,
~ I
I
Compl .. ted rer.derir.g r ollove:t
,.,
~ I
'" m,m,
/
Compl eted ter.der ir.g rollover
3t,;!.:t:t rer.del[ in.g rollover
,.,
,., m,
0 I Completed ren.de r i.n.g r ollover
I
~ I
I
,.. ro,
m,
3t.art ren.der ing J:ollover
Completed rendeJ:ing r ollove r
St .. x"" xendexing xolloveJ:
~ I '"
'55 m, Compl eted ren.dexing r ollover
/ '~O m, 3t.art ren4er ing xollover
0 I HO ro' Comp! eted ren.dexing' rollovex
/ sa = fini~he4 buildln.g edi"'ing1il
n~ I
14' I
." m,m, -
H34
St.xt renderin.g ~ideki(;lI
Compl ete4 ren.derin.g "ldell iell
,~ I')Sf-
Copyright 2010, Day Software AG. Switzerland Rev 1.5 20100907 www.day-com
•
Co.gratulatio.s! You have successfully viewed the timing statistics for a Page .
Again, t his is to aid you in reviewing t he performance of specific Pages, so that
you may meet your project's performance goals.
Goal
The f ollowing instructions explain how to change the default passwords of CQ.
This is important because it is part of t he security check list t hat will ensure
your installation cannot be easil y infil trate d by hackers. To success f ully
complete and understand these instructions, you w ill need :
When consid ering a stand ard CQ installation, there are t hree password changes
and one config urat io n you need to al ter. If you consid er a standard install ation,
and the elements invo lved, it actually becomes q uite clear. Ref lect on the image
be low:
COSE
l .. "nc~ad
(ftoljJ<!SI,ns)
config
CRX
How to change the Java .ervlet engine, (CQSE) default ad",ini,tratlve pa.sword:
2. Enter the default "User Name" (ad min) and '·Password·· (admin) - then se lect
OK.
A USe!natne and p&ssword are benl re~ed by http:/(Iocallost:'I502. The 'SIte says' "O.,y
5efvlet Enone ActrnstratlOO~
I..Jsa Name-: a~
P~SWOfd; •••••1
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 w ww clay.CQW
•
4. Ente r the "Old Password" (admin), "New Password" (training), and
"Confirm" (training) - th en sel ect Cha~ge.
""""\It,day . com
-
,
Change Password
'.
Ch ange Password :
r~ote: You r trow ser will ask "OU to re -aut he ntl cate ar.e r" th e cha nge .
,. -,
....
-
. ~. - ... , .... -,
'
... . .
......... .. - " "' .......'. ...." ,. . . ,..
"-
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.day.com
•
How to changethe cOKtent repository's (CRX) default adllliKistrative password:
CRX login
3. Enter the "User" (ad min) an d "Password" (admin) - then se lect SublllitQuery .
I
I
I-S~bmll Q-;;;;r~ r
.. .....-.- .--~ ..... . V~ · . ~_
. .. . . . . . . . /_ j
. , -. . . . . . . . . . ......... -"~ - .••. • _ . , " •.•.(
Copyright 2010, Day SoftwareAG, Switzerland Rev 1.5 20100907 www_dav com
•
4. Select User Administration.
www.day.com
Main Console
".
~ .
.(
"'- '
CRX user administration
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www"dallCom
• . .
http://localhost: 4502/crx/ui/us ...edltol .Jsp' ck= 1L
...
r;:; list. .. Create User
.•.
users
- -' a
• ad~n
• anhlyrnou$
• , aparker@Qi?ometrixx .com
• author
•
~,....,. .., " .. , ,.
.
.r:
• • • _.~ ' •• • • .' · ·, AA ... .. , . ..... ..... _ ... , .", . · ... .•
<
LM ... Create US6
~
•
/
User: adnlin
Prope rties:
t
Pr~rt)' Type Value
UserlD
Prnclp81 Name
".".,
aoollr)
(
P.!I$sword Chanoe P.!lS;;~
slroQ:re-;no . r ~ Type Strong rep :Use. U
"''''''''' st.",
v
209c61 7 ~db~9Ocaeb42-~3fa5a7ae634
I
•'\ .-~'.' " ..... -.~... *"'- ', ~'" . . . ' •." ...... •,Jr.,-, .............. .
CRX change password
Done
CO"Qratulatio",! You have successfully changed the CRX def ault administrative
password. Now focus on changing the La unchpad (Felix / Sl ing) application's
defaul t administrative password.
How to cha"ge the l aunchpad (Felix/Sli"QI applicati on's default adllli"istrative password:
2. Enter the defau lt "User Name" (admin) and "Password" (admin) - then select
OK.
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www·daV.CQro
•
A username and password are belrlQ requested by http://localhost:45Q2. The site says: "OSGi
MM1~ment Console~
Password: •••• .j
3. Select Co.flguratlo •.
/
I ~.,.,t
"
. "I ,~ ."
~~ ~ ....... ;.,
-~ - ' .- " .. " rr~ ....
...
J./
Launchpad configuration
5. Enter the new "Passwo rd" (trai ning) - then select Save.
U$t:r
'-·J a m€'
' .
.....~_. .~(r;(ord fe r the U5er allow ed to acc~::$ the OSG r··1 anagement C',
o Components ,
C C on flg uratlor
Log oe::·ervl( e
I
C e.lJndle:; ~•
,.
C Se rvices ,
EI L,·:enses ,f
~ C onil gut"atlor ::'t·3'tu:,
EJ Shell '.
Copyright 2010, Day Software AG , Switzerland Rev 1.5 20100907 WWW. da ltcom
•
How to enange tne Sling repository eredential eonfiguration:
JNDI
~, ttp :i/JC I ,d ~ y, c (' m
Pro vid er
(;av6. fI .:Imir,g prov lder.url )
f
UF L
JNDI I nrti a l Cl)m.d 1',' ,u":ll -.tndl.r· rO·.lld"" ,M~f(Jor'y In '':I" r 0: '~nT;~. t:F ~C1:0 r':,
Fa:to r " \.1.:;">10 .narnlr:g .facb) r '/ ,Inl 1311
~ nonymcllJ $
,
Userld ( :tnor \<rnous ,n ame ) ".
A nc1nyml) US
/
H,onymQU£
\
Passv. . ord (3nor yrliou ::; ,pa::;swcrd ) .i
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 WWW day.com
•
3. Validate chang es have persisted p ro perly by requesting the CQ application
and login.
NOTE
It may take a minute or two for the changes to the CRX Sling Client Repository configuration to
populate thoroughly.
Congratulations! You have successfully changed the Sling repository cred ent ial
config urat ion. Ag ain, it is important for you to have a basic und erstanding of
CQ security concerns . To learn more, you can always go to docs.day.com, and
search fo r "cq security chec kl ist".
Copyright 2010, Day SoftwareAG , Switzerland Rev 1.5 20100907 w ww. dav.CQm
•
Appendix A
Exercise - Upgrading CO 5.3 to a CRX 2.1 Repository
Goal
CQ 5.3 is bundled with CRX 2.0 . The underlying CRX repository can be
upgraded to version 2.1 for repos itory enhancements and / or bug fixes
implemented in CRX 2.1, or enhanced support for CRX IDEs, CRXDE and CRXDE
Lite :
-
CRX2.1
Repository
The following instructions explain how upg rade your underlying CRX2 .0
repo sitory to CRX 2. 1. To successfu lly complete and understand these
instructions , you will need :
• A CQ S quicksta rt JAR
• A valid CQ5 license key
• AJ D K > = 1.5
• App roximately 800 MRs of free space
• Appro ximate ly 1 GB of RAM
Copyright 2010, Day Software AG , SWitzerland Rev 1.5 20100907 www dav.com
•
As with any upgrade , you should carefully cons ider value versus risk for your
deployment. This includes testing the planned upgrade to ensure it passes you r
acceptance tests.
The recommendation not to upgrade the Apache Sling and Felix frameworks , or
any other application co mponents, ensures that the stability of the CQ5
application as a whole is retained by minimizing the changes.
CRXDE lite was a separate web application in CQ 5.3 (CRX 2.0). It is now
integrated into the main CRX web application .
Copyright 2010, Day Software AG, Switzerland Rev 1.5 20100907 www.dav.com
•
Upgr ade procedure
For the following you wil l need an account with sufficient privileges for the
various actions on files .
NOTE
For examp le. crx-2 .1 .0-enterprise.jar, w here 2.1.0 would be the <ve rsion > and
enterprise the name of the <edit ion > . Th e version might also include a date / timestamp .
For t hi s upgrade the version w ill be 2.1.0, be sure to substitute this and t he name of
your edition of CRX w herever appropriate.
NOTE
In production, before any upgrade, take a full backup of your repository. Custom
configuratio n s made in server / runtim e / O/ _crx / WEB-INF / .. will be overwritten during the
upgrade process. For example, changes to web.xml or classes/ indexin9_con(ig.xml.
Save any changes you have made and reap ply them after the upgrade_
13. Unpack the CRX 2 .1 jar file using the appropri ate fi le name. e.g .,
14. Open the CQSE admin console of your CQ 5.3 instance, for example:
Copyrig ht 2010, Day Software AG . Switzerland Rev 1.5 20100907 www_da llCQro
• --
rb
- - k __
-- -- ----
•
.........,...
'"
,<..~ ..... r" ...
_..
"".,... ~
-
t-.-'---__.... ' - . . . . _ _ AG __
15. Using the CQSE admin console , Stop the CRX Launchpad application
• Icrx
referencing the following file from the unpacked CRX 2. 1 :
crx-quickstart/server/webapps/crx-explorer_crX.war
Copyright 2010, Day Software AG , Switzerland Rev 1.5 20100907 www dav.com
•
Update the CRXDE server backend with the CQ 5.3 upgrade to
CRX 2.1 package
NOTE
The CRXDE Support package is available on Day Package Share. Please consult the
online documentation for instructions to download the package from the Day Package
Share.
Username: adrnin
Password : admin
• . .. -.....-_.
Son '"
"""
... " .... ".
, (q -doc: UmtnU.llcn - 5.}.l O.z'P
~ .. ~ • ,-"""" . <0 I~ (J. • "' ..
CfIlde-suPPOrl-contenl-2.0.0.zIP
~ •• ___ t.& ..." .$ :f'
Show
."." ....
~
,q-cOntl!nl- 5.3.2-2:' 13
..... ,. ".,.,"."'. "~ !Q. " ..
G.o ..;>,
............ m
NOTE
In case of prob lems with CQ startup, please open the Apache Felix Web Management
Console (http:// < host >:< port > / system / console)and check if all the bundles have been
started. If a restart does not help , please start the bund les manually.
• CRX
for example, http://l ocalhost:4502 / crx / index.jsp
The version details on the welcome screen will now show 2.1.
• CRXDE lite
for example, http :// 10calhost:4502 / crx / de /
The version details on the welcome screen will now show 2.1.
• CQ
use CQ to access your content, check everything is operating as
expected .
CAUTION
You must test the operation of the upg raded instance; highly customized
items may need to be upgraded separately.
NOTE
CRXDE Lite is now bundled with CRX. (and not a separate webapp), access
using l ux / de ; for example, http :// localhost:45 0 2 I crx / de t).
Copyright 2010, Oay Software AG, Switzerland Rev 1.5 20100907 Www·day.CQm