AEM Context-Aware Configurations in Java Backend Example Code
AEM Context-Aware Configurations to enable developers to define adaptable application settings based on specific site or content contexts. This feature significantly simplifies the management of environment-specific configurations, allowing for dynamic application behavior adjustment without changing the core application code. In this article, we will step through how developers can incorporate and retrieve context-aware configurations from […]
HTL caconfig Global Variable for Context-Aware Configuration in AEM
Context-Aware configuration contains a Scripting Binding Values provider with automatically registeres a caconfig variable in your HTL/Sightly scripts to directly access context-aware configurations. It supports both singleton configurations and configuration lists. Please note that configuration lists are only supported when configuration metadata is present (e.g. via an annotation class). In this article we will step […]
AuthenticationSupport service missing. Cannot authenticate request.
Encountering the “AuthenticationSupport service missing. Cannot authenticate request” OR the “HTTP ERROR 404 Not Found org.apache.felix.http.base.internal.dispatch.DispatcherServlet” errors in Adobe Experience Manager (AEM) can halt your development progress, presenting a significant obstacle. This error often points to underlying issues with the AEM instance’s ability to access or initialize critical repository services. Fortunately, there’s a practical approach […]
Generate Custom Oak Indexes with the Oak Index Definition Generator
Indexing in Adobe Experience Manager is very important. It’s not just about making things faster; it totally changes how we handle and find data online. With the Oak Index Definition Generator, developers get a really handy tool to shape how searches work behind the scenes. This tool isn’t just about making indexes, it’s about making […]
Handling Http Requests, HttpClient, in AEM
When integrating with external services or APIs from Adobe Experience Manager (AEM), utilizing the HttpClient for outbound HTTP requests is a common requirement. It’s crucial to handle these connections efficiently, securely, and in a way that is compatible with AEM’s architecture to ensure optimal performance and maintainability of your code. AEM provides a specialized factory, […]
AEM 6.5.5 Not Indexing Problem *Fixed*
In the course of establishing a new multitenant website, we opted to re-use the search mechanism for both site1 and site2. However, following the deployment of our code to the cloud QA environment, a significant hurdle surfaced: site2’s search consistently failed to produce results. This revelation made us to invest considerable effort in a detailed […]
Targeting CSS in the Editor.html for AEM Components for AEMaaCS
Sometimes as developers, we would need to inject some CSS into our pages in the edit-modes to enhance the experience of our authors. One key skill as an AEM developer knowing how to customize the authoring experience in the editor.html (while content authors are editing the page). This article explores the techniques of targeting CSS […]
Benefits of SlingSafeMethodsServlet with Code Examples
A robust security strategy is pivotal to safeguarding applications. As an AEM developer, we must really understand the SlingSafeMethodsServlet, an invaluable feature within the Apache Sling framework. This article explores the core concepts, practical benefits, and the heightened security it brings to servlet development. The org.apache.sling.api.servlets.SlingSafeMethodsServlet is an extension of the trusted HttpServlet in Apache […]
Try-With-Resources: Ensuring Session Closure, AEM Code Example
In the dynamic realm of Java programming in AEM, effective resource management is a cornerstone of writing robust and reliable code. The “try-with-resources” statement, introduced in Java 7, emerges as a powerful ally in simplifying resource handling. This article delves into the practical implementation of “Try-With-Resources” within the context of a specific code snippet, emphasizing […]
AEM Convert Excel to JSON Simple Servlet Example
In this article, I present a straightforward yet powerful solution that demonstrates how to seamlessly convert Excel data into JSON format using Adobe Experience Manager (AEM). By implementing a custom servlet, I will illustrate the process of converting an Excel sheet named ‘example.xlsx’ into structured JSON data; it can be downloaded below for you following […]
JCR SQL2 ISDESCENDANTNODE Multiple Paths Example
While working with the JCR SQL2 Queries, you may encounter scenarios where content is distributed across various branches of the repository. Querying these branches efficiently is key to implement features to capture requirements. In this article, we will focus o how to collect and query for distributed across various branches of the repository. Using the […]
Optimizing & Debugging Search Queries, Explain Query Tool AEM
The “Explain Query Tool” tool assists developers in understanding, optimizing, and debugging search queries, which are crucial for the AEM’s performance and accurate content delivery. Understanding the Explain Query Tool The Explain Query Tool essentially breaks down and explains the steps and processes a query goes through in AEM. Think of it as a ‘debug […]
Retrieving the Current Page in an AEM Servlet via ResourceType
In the context of “Retrieving the Current Page in an AEM Servlet via ResourceType”, it is great to understand how this is done. This guide provides a simplified walkthrough on how you can adeptly achieve this. In the code example, we will associating the servlet with a resourceType. 123456789101112131415161718192021222324252627282930313233343536373839package com.example.aem.servlets; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import […]
AEM 6.5 On-Prem, Embed AEM Core Component’s to the Project
The AEMaaCS platform contains the Adobe AEM Core Components pre-installed into the /libs folder, but however, AEM 6.5 on-prem does automatically contain this; we must install it manually. For legacy AEM 6.5 project utilizing the Adobe AEM Core Components, they must configure & install this library to each environment (authors, publishers) with the correct version. […]
How to Embed wcm.io Context-Aware Configuration Editor
This blog article serves as your guide to seamlessly integrate and deploy the wcm.io Context-Aware Configuration Editor – a powerful tool that streamlines configuration management within AEM projects. Throughout this article, we will delve into the step-by-step process of configuring, installing, embedding, and deploying the wcm.io Context-Aware Configuration Editor. By following these instructions, you’ll be […]
AEM Sling Servlet: resourceTypes for POST & GET Code Example Code
When working with Sling Servlets in AEM, the choice between using a resource type or a sling path as the basis for your servlet’s operation is crucial. This article delves into the benefits of utilizing resource types and provides practical examples of how resource types can streamline your development process for both POST and GET […]
AEM JCR SQL2 Full Text Search Case Insensitive
One of the key features of AEM is its support for searching and querying content stored in its Java Content Repository (JCR). In this article, we will explore how to perform a case-insensitive full-text search using the JCR_SQL2 query language in AEM and provide a practical example of achieving this through a servlet. Performing Case-Insensitive […]
How to access Design Dialogue Properties in Sling Model
Design Dialogs are especially useful for creating components that need to be easily configurable through editable template and policies without directly editing the underlying code. They enable a clear separation between content and presentation, allowing content authors to make changes without needing technical expertise. Design Dialogs are defined using the AEM Touch UI Dialog, which […]
JUNIT 5: JCR SQL 2 Unit Tests w/ Sling Servlet
I’ve dedicated quite a chunk of my personal time to crafting this blog post, and yes, I’ve rigorousl… This page is premium content. By supporting this website, please subscribe. Subscribe now for $1 for 1 month of premium content. Username or E-mail Password Remember Me Forgot Password
Search in AEM
This comprehensive guide offers AEM developers like you a roadmap to implement powerful search functionality using AEM Search APIs. Unravel the potential of three core AEM Search APIs: XPath Search API, JCR SQL2 Search API, and Query Builder Search API. Each API brings unique features to the table, and we’ll guide you through their capabilities […]
Query Builder API Exclude Pages or Paths
This blog article focuses on searching cq:Page under a particular path, but exclude sub pages. In this article we will share you the Query Builder API’s Query, and share with you the Java code implementation of a servlet. At the end of this article, you should be able to search cq:Page nodes under a particular […]
50 Visual Studio | VS Code Hot Key / Shortcuts for Mac 2023
Welcome to our guide on 50 Visual Studio Code shortcuts for Mac users. Whether you’re a seasoned developer or just starting, mastering these keyboard shortcuts will significantly enhance your coding productivity. Let’s dive in and discover the most efficient key combinations for a seamless coding experience! For Window users, visit this article, 50 Visual Studio […]
50 Visual Studio | VS Code Hot Key / Shortcuts for Windows 2023
Welcome to our guide on 50 Visual Studio Code shortcuts for Windows users. Whether you’re a seasoned developer or just starting, mastering these keyboard shortcuts will significantly enhance your coding productivity. Let’s dive in and discover the most efficient key combinations for a seamless coding experience! For Mac users, visit this article, 50 Visual Studio […]
AEM Sightly Official Documentation: Everything You Need to Know
This blog particularly promotes Adobe’s AEM Sightly documentation, which lives inside of their github repository. In this article, we’ll explore the significance of AEM Sightly and how its official documentation can be a valuable resource for developers working with Adobe Experience Manager. With understanding Adobe’s Sightly documentation, you will be equipped with the right tools […]
AEM RichText Remove P Tag on Sightly
You may have been trying to search the internet for an out of box solution to remove the single paragraph container for Touch UI, and have found something like removeSingleParagraphContainer. But however, this attribute was for the Classic UI and deprecated. From my knowledge, there isn’t anything out of the box that can remove the […]
Why Indexing in AEM is so important for Search
As we are developers implement search, I would like to share the importance of indexing in AEM. I would like to express that this is a simple post, but enough information to get you to understand the importance of indexing. Continue and read the article below to see the significance & Importance of Indexing in […]
AEM Effective Pagination with Query Builder API
There are many ways to implement pagination for AEM content. Effectively choosing the right solution will indeed Bu decrease development time, and promote a performant experience to your end users. AEM has multiple search API’s like xPath, JCR SQL2, Node JCR, Query Builder, etc… But in my opinion, the Query Builder API would be the […]
A Simple Guide to AEM Search APIs: Exploring Your Options for Powerful Search Functionality
As an AEM developer, the ability and skill to identify solutions and implementations to quickly and efficiently search through vast amounts of content is crucial. Understanding the all the AEM platform’s search API capabilities will ensure you are a effective developer, when implementing solutions for AEM search. In this article, we will explore the various […]
AEM Query Builder Examples with Content Fragments
In this article, I will share some example AEM Query Builder API Search Queries that queries for Content Fragments. 1. Find all Content Fragments with Content Fragment Model 123456type=dam:Asset path=/content/dam/sourcedcode boolproperty=jcr:content/contentFragment boolproperty.value=true property=jcr:content/data/cq:model property.value=/conf/sourcedcode/settings/dam/cfm/models/model1 http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&query=type%3Ddam%3AAsset%0D%0Apath%3D%2Fcontent%2Fdam%0D%0Aboolproperty%3Djcr%3Acontent%2FcontentFragment%0D%0Aboolproperty.value%3Dtrue%0D%0Aproperty%3Djcr%3Acontent%2Fdata%2Fcq%3Amodel%0D%0Aproperty.value%3D%2Fconf%2Fsourcedcode%2Fsettings%2Fdam%2Fcfm%2Fmodels%2Fmodel1 2. Find all Content Fragments with Content Fragment Model & Property 12345678type=dam:Asset path=/content/dam/sourcedcode boolproperty=jcr:content/contentFragment boolproperty.value=true 1_property=jcr:content/data/cq:model 1_property_1.value=/conf/sourcedcode/settings/dam/cfm/models/model1 2_property=jcr:content/data/master/title 2_property.value=example http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&query=path%3D%2Fcontent%2Fdam%2Fsourcedcode%0D%0Aboolproperty%3Djcr%3Acontent%2FcontentFragment%0D%0Aboolproperty.value%3Dtrue%0D%0A1_property%3Djcr%3Acontent%2Fdata%2Fcq%3Amodel%0D%0A1_property_1.value%3D%2Fconf%2Fsourcedcode%2Fsettings%2Fdam%2Fcfm%2Fmodels%2Fmodel1%0D%0A2_property%3Djcr%3Acontent%2Fdata%2Fmaster%2Ftitle%0D%0A2_property.value%3Dexample […]
@SlingServletPaths Example Code in AEM
This is a quick reference to example code, which will show you how to use the most base instantiation of @SlingServletPaths. The output is a simple JSON response with application/JSON, 200 OK, and response body = { “property1”: “value1” }. Quick note: it’s not recommended to use @SlingServletPaths. Check out the caveats when implementing servlets […]
AEM Style System Component Information with Code Sling Models
As an AEM full-stack web developer who frequently works with AEM components, it’s not uncommon to require access to the AEM Style System configuration of a specific component. This information can prove invaluable when writing conditional algorithms to manipulate data output. However, the question remains: how can one retrieve the necessary AEM Style System information […]
Checking run mode from Sightly HTL in AEM in 2023
While we are developing in the modern world of AEM, sometimes we may want to understand if our backend implementation is being executed under “development”, “staging”, and “production”. In the past, we use the SlingSettingsService, but unfortunately, the SlingSettingsService is flagged as a deprecated service in AEM. According to one of the most prominent AEM […]
Set AEM Local Environment and Secret Variables AEMaaCS
As an AEM developer developing for the AEMaaCS SDK, it’s essential to have a local environment properly set up for development purposes. You may encounter environment-specific and secret variables in your OSGI configuration files. As an AEM developer trying to familiarize new features of the AEMaaCS SDK development environment, setting up environment-specific and secret variables […]
AEM Sightly Component(s) Empty CQ PlaceHolder
In almost all cases, component’s that are not configured, dragged onto the page should have some sort of indicator telling content authors that they should configure the component; a few of us calls this the empty component placeholder or “cq-placeholder”. A novice AEM full-stack may not be geared with the right tools, and so they […]
AEM Developers Courses 2023 That Really Helped Me
There are a couple of courses that I would like to share that have really helped me, not just in interviews, but also in my daily AEM development regime. In my opinion, I think these are the best courses for anyone who is either getting started as an AEM developer or who is already working […]
AEM Programmatically Write/Update/Modify AEM JCR node property/properties
In this article, I will be presenting code snippets for how we can programmatically update AEM JCR nodes in AEM using Java; using the org.apache.sling.api.resource.ModifiableValueMap and javax.jcr.Node API. In this article, we are showcasing the way that you would programmatically update AEM JCR nodes in your local machine, logged in as a System Users in […]
Deploying Core Module of the AEM Project
For rapid AEM backend developer, we would like to build the AEM core module bundle to our running local AEM instance. In this article, we will configure the core bundle with an automated script. Simple build the project with mvn clean install -PautoInstallBundle. This is actually a standard that is shipped from the aem-project-archetype-39, but […]
Create System | Service Users in AEM 6.5 with Code Configurations
In this article we will walk through how to configure your AEM project to have the AEM environment self configure System Users in AEM with code, so that you would not need to do it the manual way. With the leverage of the org.apache.sling.jcr.api v2.4.0 bundle provided by AEM 6.5.4+ or AEM as a Cloud […]
resourceResolverFactory.getAdministrativeResourceResolver(null) WhiteList Bundle for Administrative Login
When working for organizations with the goal of migrating from AEM 6X to 6.5 or to AEM Cloud as a Service. It’s very common that the AEM backend code still utilizes the deprecated resourceResolverFactory.getAdministrativeResourceResolver(null) @depricated API. This method has been deprecated as of 2.4 (bundle version 2.5.0) because of inherent security issues. Services requiring specific […]
AEM Sightly Comments with Examples
When writing comments in your Sightly HTL file, it’s best practice not to use HTML comments, but to use the sightly, HTML Template Language. 1. HTL comments are not evaluated and returned back as an empty string in the server-side rendered results. This is best practice when developers are including some comments for other developers […]
What are AEM ExtraClientlibs?
When dealing with cq:ClientLibraryFolder (node type), you may have come across a property called extraClientlibs. What are extraClientlibs and how does it work? As you may recall, when you want to add custom functionality or styling to the Touch Dialogues (in edit author mode, editor.html), we must include cq.authoring.editor.sites.page as a dependency and cq.authoring.editor.sites.page.hook as […]
What Version Sightly, Apache Sling Scripting HTL Engine, is my AEM Using?
How do I find out which Sightly, Apache Sling Scripting HTL Engine (runtime) version is being used in my AEM environment? You may want to know because while writing code, you would want to know which API is avaiable to use. The Apache Sling Scripting HTL Runtime provides support for executing HTL Java compiled units […]
Find all AEM Pages with Specific Page Properties with Query Builder API
The Query Builder is a great tool that allows us to search for nodes in the JCR. We often as AEM developers use this tool to build a query for us to use in the backend to build query descriptions (predicates); the set of predicates produced will call the Predicate Evaluator which knows how to […]
Granite UI Multifield Sightly Traverse | Iterate Simple Example
In this article, we will share an example on on how we can iterate and traverse through multifield nodes that have been generated by the Touch UI using Sightly in a very simple way. Going through this article, we will be setting up multifield Granite UI links (as if we are building a menu navigation). […]
HTL Java Use-API Code Example
The HTML Template Language (HTL) Java Use-API allows an HTL file to use data-sly-use to access helper functions in a custom Java class. This allows any sophisticated business logic to be wrapped in Java code, while the HTL code is just responsible for direct markup generation. A simple POJO can be used as a Java […]
Checking run mode from Sightly HTL in AEM
Sometimes during development, we would need to check the run mode in our AEM environment, so we can show different content based on the context. From the Sightly HTL API, it’s possible to check for the wcmmode, but not the runmode. In this article, we will set up a sling model helper which will be […]
How to Generate Unique AEM Component ID with Confidence
You frequently require a special ID for the AEM component. Either a backend server-side call or a custom JS action trigger are required. If the component is dragged and placed on the page more than once, the hard-coded field ID is not guaranteed to be unique. When considering ID, you might consider directly using the […]
Find all AEM Pages with Tags with Query Builder API
The Query Builder is a great tool that allows us to search for nodes in the JCR. We often as AEM developers use this tool to build a query for us to use in the backend to build query descriptions (predicates); the set of predicates produced will call the Predicate Evaluator which knows how to […]
Send Out Emails with AEM Servlet
In this article, we will be setting up the local AEM author developer’s environment to send out an email utilizing the Day CQ Mail Service. This article includes code snippets to a Sling Servlet that will be used to send out the email. We will be using a Google Gmail account as the SMTP Mail […]
Set Cookie Example of AEM Servlet and Sling Model
In this short article, we will show two code examples; for example, one will be showcasing how cookies values can be set for an AEM Servlet, and for example two, Sling Model. 1. AEM Servlet Set Cookie Example 12345678910111213141516171819202122232425262728293031323334353637package com.sourcedcode.core.servlets; import com.cat.wcm.core.util.JSONObject; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.servlets.SlingAllMethodsServlet; import org.osgi.service.component.annotations.Component; import javax.servlet.Servlet; import javax.servlet.http.Cookie; import […]
How to Dynamically Include an Experience Fragment in Sightly
In this article, we will dynamically reference an AEM experience fragment to a page, dynamically using code. Sightly Implementation Hard Coded Example The first example uses sightly to reference an experience fragment, /content/experience-fragments/we-retail/equipment, and the required variation, master. This will only work when the path includes the experience fragment variation path. The value here is […]
Find AEM JCR Nodes with Full Text Search
Every AEM developer knows that a JCR node consists of properties and values. Whenever a component is configured or whenever page properties are set, the value is saved in the JCR node as properties and values. There are times when we would like to search all the JCR node properties, to match the value with […]
AEM IntelliJ Debug Error:osgi: [sourcedcode.core] Classes found in the wrong directory: {META-INF/versions/9/javax/xml/bind/ModuleUtil.class=javax.xml.bind.ModuleUtil}
Writing unit tests for AEM Backend code on IntelliJ can sometimes be challenging; mocking objects, initializing OSGI components, etc… It’s most beneficial when we can write unit tests utilizing the JUnit debug feature on IntelliJ. While trying to debug code in JUnit, I was getting an error of 1Error:osgi: [sourcedcode.core] Classes found in the wrong […]
ACS Commons multi-field extension, acs-commons-nested, checkbox is not working
This article will provide a solution to the ACS Commons multi-field extension, checkbox Granite UI Component. While utilizing the ACS Commons multi-field extension, for everything I tried, I am not able to get the checkbox Granite UI component working as expected. Not an elegant way to solve the problem, but something that actually works and […]
AEM RichText Remove P Tag, removeSingleParagraphContainer, for Touch UI
You may have been trying to search the internet for an out of box solution to remove the single paragraph container for Touch UI, and have found something like removeSingleParagraphContainer. But however, this attribute was for the Classic UI and deprecated. From my knowledge, there isn’t anything out of the box that can remove the […]
How to Pass Data Parameters to WCMUsePojo from Sightly HTL Component
You can pass data parameters from Sightly HTL component to the WCMUsePojo backend in a very simple way. You can simply call the get(String name, Class type) method from the available public methods from the com.adobe.cq.sightly.WCMUsePojo class. For implementation, use the get(String name, Class type) method, we obtain the values sent from Sightly as attributes; […]
How to Pass Data Parameters to Sling Modal from Sightly HTL Component
You can pass data parameters from Sightly HTL component to the Sling Model backend by request attributes. For implementation, utilising the org.apache.sling.models.annotations.Model, we will add required options parameter, adaptable, with the value of SlingHttpServletRequest.class. Next, we can utilize the annotation, org.apache.sling.models.annotations.injectorspecific.RequestAttribute (@RequestAttribute), which will find the matching name of the attribute that is being passed […]
Update a Node JCR property in AEM with CURL
This is a simple way to update or write a Node JCR property inside of AEM using curl. curl command: 1curl -v -u admin:admin -X POST http://localhost:4502/content/sourcedcodeaem/jcr:content –data-urlencode ‘isCurlWorking=true’ Result: If you wish to learn how to Update Multi-Value Node JCR properties in AEM with CURL, click here.
Update Multi-Value Node JCR properties in AEM with CURL
This is a simple way to update or write multi-value Node JCR properties inside of AEM using curl. curl command: 12345curl -v "http://localhost:4502/crx/server/crx.default/jcr%3aroot" \ -u admin:admin \ -H ‘Content-Type: multipart/form-data; boundary=crxde’ \ –data-raw $’–crxde\r\nContent-Disposition: form-data; name=":diff"\r\nContent-Type: text/plain; charset=utf-8\r\n\r\n^/content/sourcedcodeaem/jcr:content/stringArray : ["one","two","three"]\r\n–crxde– ‘ \ –compressed Result: If you wish to learn how to […]
How to get Authorization: Basic Auth Header from AEM Author
Getting the Authorization (Basic access authentication) Basic Auth Header from AEM Author is simple. If you have curl installed on your machine, simply run the command below, and you should be able to get the Authorization header from a successful AEM login. What we are doing here is logging into the AEM author with curl […]
DRY way of using RichText Granite UI Component in AEM for Static Templates
Every developer have experienced a situation where they are working with AEM multiple AEM components, where Touch UI dialogues consist of a common richtext Granite UI component configuration cq/gui/components/authoring/dialog/richtext. When I mention common richtext Granite UI component, I mean there are multiple AEM components that will have the richtext Granite UI component as one of […]
taglib prefix=”sling” to Sightly and Sling Model Non-JSP & Non-JSTL implementation
In the past, AEM developers would heavily focus on building AEM components with Java Server Pages (JSPs) & JavaServer Pages Standard Tag Libraries (JSTLs). There are special JSTLs for AEM JSP components to speed up the development. One popular JSTL is called the Sling Taglib. The Sling Taglib is popular when it comes to writing […]
How to Get AEM i18n Dictionary in JSON Format
AEM i18n dictionary out of the box tools does not offer an elegant way to get the JSON representation of targeted the i18n dictionary. Without out of the box AEM i18n dictionary JSON formatting tools, we first solutionize to what we know the most. As of AEM developers, we all know that we can trigger […]
Errors while building the latest AEM Project Archetype 24 on MacOS
I was recently trying to start up a new AEM project using the latest, AEM Project Archetype 24, but I was having having some build problems indicated in the errors below: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143$ mvn -B archetype:generate \ > -D archetypeGroupId=com.adobe.aem \ > -D archetypeArtifactId=aem-project-archetype \ > -D archetypeVersion=24 \ > -D appTitle="AEM SourcedCode" \ > -D […]
Tool: Generate Curl Command to Update OSGI Configurations
Micro-Frontend, written in ReactJS 16.14.0. This tool helps generate a curl command used for updating OSGI configurations directly from the terminal, bash, or Window’s console. It’s a good idea to read the micro-front-end tool’s notes, described at the bottom of the page, before using the tool. AEM Curl Generator for Updating OSGI Configs This tool […]
AEM inheritedpageproperties with Sightly, JSP, OSGI Bundle
inheritedpageproperties helps you retrieve a parent property from parent pages. Inherited page properties utilises com.day.cq.commons.inherit.HierarchyNodeInheritanceValueMap, where the search is made on the page hierarchy, upwards; searching children of the page nodes (components) are not included. Inherited page properties can be retrieved in multiple ways, where this article will only focus on 3 ways. In this […]
Basic Steps to Debug an Error in AEM
There are times when something is not working as expected from the AEM Server; relax, you are fine. The error can be quickly identified through debugging on the server with a series of steps. Once the error has been identified you can attempt to solve the error efficiently. In this article, I will share with […]
How to Enable Configuration for OSGI Components with R6
Adding configuration to OSGi Component(s) is as simple as annotating your class with @Designate(ocd=””) annotation with the “ocd” property, and to make the @Activate method accepts an config param; as indicated below: 1234567891011121314// /com/sourcedcode/services/impl/MyserviceImpl.java import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.metatype.annotations.Designate; @Component(service = MyService.class, immediate = true) @Designate(ocd = SourcedCodeSiteSettingsConfig.class) public class MyserviceImpl extends MyService { […]
OSGI R6 Configuration @AttributeDefinition Essentials Reference Guide
When defining any OSGI component’s configuration its standard practice to use Declarative Services; these configurations can be edited in the OSGI Apache Felix Console. This can be done by creating a class interface with the annotated @ObjectClassDefinition, which includes a determined list of rules as @AttributeDefinition items. The @AttributeDefinition defines the supporting configuration for a […]
Creating a Basic AEM Touch UI Dialogue
In this article, we will step through the steps of creating a new Touch UI dialogue configuration within your AEM maven project. Code examples will showcase a basic Granite UI form container & component. Create basic Touch UI Dialogue Within your AEM maven source code, create create a “_cq_dialogue” folder under your targeted component. Example: […]
How to Convert Adobe’s Granite UI 1.0 Documentation to XML
As an AEM developer, we must prepare Touch UI dialogues within code, in the XML format. When it comes to reading the Granite UI 1.0 Documentation, it can be confusing; especially for new AEM developers. These new AEM developers are confused by how properties within the documentation are mapped and converted to XML entries. This […]
AEM Granite UI 1.0 Form Component’s XML Cheat Sheet Reference Guide
This AEM Granite UI 1.0 Form Component’s XML Reference Guide provides code snippets to help developers speed up their AEM Touch UI development. This quick reference includes the most used Granite UI form components with plug and plays XML examples. Note: If you want to understand how to convert Granite UI 1.0 Form Components from […]
AEM Sling Model Constructor Injection
Sling Models field injection, @inject, are used to support injection of AEM Library-specific context objects. However, there is an alternative way to inject AEM objects into Sling Models, and its called Constructor Injection. The benefits of Sling Model Constructor Injection: Does not store the injection references to the adaptable. Since it does not store injection […]
AEM Sling Model Field Injection vs Constructor Injection Memory Consumption
Article was last updated on June 7th, 2020. Sling Models field injectors are used to support injection of AEM Library-specific context objects. For example, @ScriptVariable SightlyWCMMode will inject the WCMMode object, @ScriptVariable Resource will inject the current resource object, and @ScriptVariable Style will inject the Style object. These objects are typically stored within the object, […]
AEM Sling Model Injectors Annotations Cheat Sheet Reference Guide
The Apache Sling Model enables injector specific annotations which aggregate the standard annotations for each of the available injector, which are: Script Bindings, Value Map, Resource Path, Child Resources, Request Attributes, OSGI Services, Self, and the Sling Object. Sure we can invoke injectors by the @inject, followed by the @source annotation (with an injector name) […]
JUnit 4: AEM Sling Servlet Unit Test Example Using wcm.io AEM Mocks, Servlet by Resource Type
This article will demonstrate how to write AEM Unit tests for @SlingServletResourceTypes (OSGi DS 1.4 (R7) component property type annotations) using the Junit4 testing framework. With developers being more visual, the source code is posted below. Technologies here used are: AEM project archetype 19 (link) Mockito 2.27.0 (link) AEM Mocks JUnit 4 2.7.2 (link) This […]
Registering @SlingServletPaths Component Property Type
You are probably looking for the @SlingServletPaths, OSGi DS 1.4 (R7) component property type annotations for Sling Servlets, code/unit test examples and was not successful. Apache recommends not use the @SlingServletPaths annotation, Sling Servlet register by a path. Rather to use the @SlingServletResourceTypes component type. Given the drawbacks in the caveats below, it is strongly […]
Sugar Coat Registered AEM Servlet Scripts and Paths Endpoint
In AEM we tend to write Sling Servlet OSGI Services to expose JSON data using the various service reference properties such as “sling.servlet.paths”, “sling.servlet.resourceTypes”, “sling.servlet.selectors”, and “sling.servlet.extensions”. Example 1: DirectoriesServlet.Java doGet Servlet Implementation (html extension): This is an example how a servlet in AEM to retrieve the directories JSON data. 1234567891011121314151617// example for /content/mysite.directories.html @SlingServlet( […]
What is a Servlet in AEM?
What is a Servlet? A Servlet is a class used to extend capabilities of servers that host applications accessed by means of a request-response programming model; we know most the HTTP protocol. In AEM, Servlets are typically registered as an OSGI service. The reference of the “sling.servlet.paths” or “sling.servlet.resourceTypes” must be set, or the Servlet […]
Improve Performance of AEM Components During Development Phase
Web performance is how quick web pages are successfully downloaded and viewable on the visitor’s browser. When we say “Web Performance Optimization”, this means that we are optimising or increasing web performance. Quicker download speeds of websites, in general, have shown in user contentment, retention, and loyalty. Especially with AEM enterprise websites, our motive is […]
Scenario: Building AEM Components with 3rd Party Integrations in a High Performance and Scalable Way
we are assigned to build a hospital search component in a very high traffic website. This hospital search component allows users to search for available hospital private rooms across the United States; there are approximately 200,000 hospital private rooms across the US. The hospital search component, presented in the view, simply has an input field […]
How to Check all Active Run Modes in a Running AEM Instance.
The fastest way to retrieve all active run modes that are enabled within a running AEM instance would be from the OSGI console, Apache Sling Settings. Follow the two simple steps below: Log in to AEM as an admin or a user who has access to the OSGI console using this URL: http://localhost:4502/crx/de/index.jsp Navigate to […]
How to write Javascript Unit Tests for AEM Client Libraries with Jest
This article demonstrates how to set up and run Javascript Jest unit test for client libraries. As a part of this setup, code coverage will be produced by Jest. With this implementation, we will utilise the frontend-maven-plugin, where it makes it possible to run npm scripts apart of the maven build. Most of the time, […]
JUnit 4: AEM WCMUsePojo Unit Test Example (Passing Paramaters)
This article will demonstrate how to write AEM Unit tests for building WCMUsePojo Java classes using the Junit4 testing framework. With developers being more visual, the source code is posted below. In this example, I am building a Sightly utils class that helps me append .html to page path that are configured by the author. […]
AEM Project, WCMUsePojo “aQute.bnd.annotation.ConsumerType not found” (fix)
On rare occasions, when developing a Java class that extends WCMUsePojo class, you will get the error of “class file for aQute.bnd.annotation.ConsumerType not found“. This problem can be easily solved by adding the dependency to your parent-pom.xml and core-pom.xml as shown below: 123456789101112131415//parent-pom.xml <!– https://mvnrepository.com/artifact/biz.aQute.bnd/bndlib –> <dependency> <groupId>biz.aQute.bnd</groupId> <artifactId>bndlib</artifactId> […]
How to use AEM JCR SQL2 query strings to query for nodes in Java Content Repository
JCR-SQL2 (Java Content Repository – Structured Query Language 2) is domain specific language used to query JCR nodes held in the JCR repository. The syntax for JCR-SQL2 is fairly similar to SQL, so if you have some experience with SQL, this tutorial will be a walk in the park for you. The best way to […]
How to make a simple HTTP POST request to AEM with a HTTP Rest Client, Postman
This method should be used for DEVELOPMENT PURPOSES ONLY! During development in the AEM author instance, you would like to test your servlet using an HTTP Rest Client such as Postman. When making a POST request on the Rest Client, you will experience 2 errors. An authentication error, and a 403 forbidden error. What’s Happening? […]