Posts

Need for Query and Index in AEM

Image
For functionalities like full text search, retrieve content based on certain property or conditions associated with property/to avoid iterations on huge volume of content under the root, we write query based logic in AEM. Languages supported : XPATH JCR-SQL2  XPath: Created using AEM Query Builder API. - com.day.cq.search.* From development point of view, we need to be aware of standard OOB predicates to arrive at XPATH query. JCR-SQL2: JCR-SQL2 queries are created using QueryManager - javax.jcr.query.QueryManager QueryManager is acquired through JCR Session  - session.getWorkspace().getQueryManager() Query Processing: Before AEM 6.0/Jackrabbit 2, everything in AEM is indexed by default. With Jackrabbit Oak, we can create custom indexes based on the need. OOB indexes are available under /oak:index node in the repository. Oak Query Engine Process queries in the form of JCR-SQL2.  This means if we write queries using QueryBuilder API involvi...

Content Fragments in AEM - High level pointers

Image
Content Fragments(CF), an implementation for re-using content across multiple locations/channels, a means for headless-CMS. jcr:primaryType Content Fragments(CF) is of asset type - dam:Asset  to hold mixed media content - Text and Assets. Types Simple Fragment, Created out of Fragment Template named " Simple Template " OOB Structured Fragment, Created out of Content Fragment Model(CFM) Note :   Per 6.5 Adobe docs, it is recommended to create CF using CFM. Simple Template Defines single "Multiline text" element. Content Fragment Model(CFM) Offers different data types to define the type of content.(Single line, Multiline text, Date field, Numberfield, dropdown and so on OOB and an option to render each of this in multifield format as well. ) Elements Each of this data types that we define as part of CFM is referred to as  Elements in CF Mutiline Text element It is available in 3 types/formats Rich Text, text/html Plain Text, text/p...

OSGI Factory Configuration implementation

OSGI Factory configuration is used to have many instances of an OSGI config (represented/identified via an identifier) for the single OSGI service/PID. Most often used OOB Factory configurations for example: Logger Factory/writer configuration (for log statements) Service user Mapper service Amendment (for using service resource resolver in projects) Few sample real time use case for the need of OSGI factory config: For multi tenant projects, if we have generic service used across tenants with properties/attributes specific to tenant. For single tenant, generic service targeting all locales with properties/attributes specific to locale. (where generic service -> holds logic in the lines of calling third party service for retrieving/updating information.) Implementation: ( In terms of OSGI R6 annotations ): Create Object Class Definition(OCD) defining desired properties for the OSGI service. - OSGIFactoryConfigOCD.java OSGI Service/Factory service to retrieve ...

Custom xfpage component/template for Experience fragment

Image
Experience fragment(XF) is a page in AEM, like we have our project site pages of the type cq:Page.  Given that it is a page, it is backed by a template and hence a page component.  Site specific XF Page component( inheriting from OOB xfpage component ) -> Template Type -> Editable Template -> XF page -> Use in site pages via OOB "Experience fragment" component(from the componentGroup - General) When we develop a new site, we do create page component with supertype as OOB page component( wcm/foundation/components/page ) or core v1/v2 page component( core/wcm/components/page ) Likewise, for XF specific to our site, we are creating one inheriting from OOB XF page component.  OOB XF page component :   /libs/cq/experience-fragments/components/xfpage. Site specific XF page component: Create a component with super type being /libs/cq/experience-fragments/components/xfpage. We need to override two files customheaderlibs.html and customfo...

AEM page load time

Image
In the process of debugging performance issues, we need to narrow down the load time of the page and hence the individual component/requests part of the page. Below are the few ways of finding out the same.  From Browser : The very first place where we look for the page load time is our browser's Developer tools->Network Tab  which will display the time taken for each of the requests that are part of the page. AEM Component load time: We have an OOB feature on the AEM Sites page to find out the load time of a component.  Open AEM Site Page in editor mode(with /editor.html) -> Switch to Developer mode from Edit mode -> Left rail in content finder area -> Components section -> Components available as part of the page will be displayed with the time taken. request.log:   request.log file available in ../crx-quickstart/logs folder will have a trace of each and every request and its duration.  There exist a Request Log Analy...

Experience Fragments and Content Fragments - High level differences

For reusing content, we have two great implementations available in AEM - Experience Fragments(XF) and Content Fragments(CF). It is important to understand the differences between the two which will help us arrive at when to use what based on our project/content set up.  Experience Fragments Content Fragments Composed of one or more AEM components Composed of structured/form-based data elements The content part of XF is any  AEM components  as such - Text, Image or any custom component part of our project. ie. Presentation-centric  The content part of CF is  text/image content  in the form of direct text type/RTE/Date type/Dropdown/Reference type for referencing any asset ie. Content-centric Created using Editable templates , implemented/treated as an AEM Page Created using Content Fragment Model , implemented/treated as an AEM Asset List of allowed components in XF can be controlled via policies in Editable templates Content ...

"cqDesign" variable in Expression Language(EL)

Apart from the supported variables/functions in Expression Language, we can have custom variable created with help of ExpressionCustomizer( com.adobe.granite.ui.components.ExpressionCustomizer ) and the same can be made use of in Expression Language. One such variable is cqDesign used to fetch design properties as we do with currentStyle . Implementation Details: Design design = getDesign(); ExpressionCustomizer customizer = ExpressionCustomizer.from(request); customizer.setVariable("cqDesign", design); Usage in granite:hide: granite:hide property with cqDesign variable in EL has been used widely in Core Components. Illustration of Core List component related to this with screenshots has been mentioned in helpx link It controls the list displaying options of dialog using values/properties configured in Design mode of List component(in case of static template) or via Policy of List component (in case of Editable template) Given that "cqDesign" is associ...