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 Setup the AEM Dispatcher Flush Agent?
Before setting up the dispatcher flush agent on your AEM publish instance, we must make available the /dispatcher/invalidate.cache URI. Where is exactly the /dispatcher/invalidate.cache endpoint coming from? In this article we will answer how is the /dispatcher/invalidate.cache generated, how do we securely allow only specific IP addresses to make a flush cache request, and how […]
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 […]
Re-usable Color Select in Touch UI Dialogs w/ ACS Common’s Generic Lists
While working on AEM component’s Touch UI dialogues, in particular, with colors, there are many cases where developers will need to configure the same color options over and over again. We catch ourselves repeating code, which becomes uneasy to maintain changes to the color options. What happens when there is a new color option? Going […]
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 […]
With HTL, Pass Data from AEM Backend to Javascript
When working with AEM components, it’s very common to pass data from AEM backend to a particular JavaScript event. In this article, we will be focusing on how to pass data from AEM backend using the HTML data-* attribute. HTML data attributes were designed apart of HTML5 where these attributes allow developers to store data, […]
3 Different Ways to Embed Custom Fonts in AEM Sites
In this article, we will go through three different ways how you can embed custom fonts in an AEM site. Embed Custom Font using Google Fonts, CDN Embed Custom Font using Adobe Fonts, CDN Embed Font via AEM Client Library Static Asset Importing fonts from other services such as Google Fonts or Adobe fonts could […]
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 […]
AEM RichText Max Characters Length Validation
In this article, we will take a look at how we can add max character length validation to the richtext component, cq/gui/components/authoring/dialog/richtext, by introducing a maxlength attribute. The validation will be executed whenever AEM authors try to save or perform an on-key-up action after applying changes within the richtext input field. After implementing the solution, […]
How to include JavaScript for an AEM Website
Adding behaviour to a form, button, list of items, or page scroll are some examples of front-end user interactions that we as developers must implement, to enable user rich experiences. How do we add behaviours to a page? JavaScript! JavaScript is the technology used to add user rich experiences for a website. AEM website can […]
How to Serve Static Assets in AEM as Client Library Resources
This article provides step by step instructions on how to create a client library, to only serve structural static assets as client library resources. Resources from this article will build upon the latest maven AEM Project Archetype, and the instructions below will demo the configuration setup within the code. Mention! Learn more about the reasons […]
Structural Static Assets in AEM as Client Library Resources
As developers, when we are building components or view logic, in typical scenarios require assets like background image patterns, icons, logos, typography, etc.. These assets are considered as structural assets. Structural assets are assets that support CSS styles or JavaScript view logic; which are also static assets. Structural assets should be stored and managed within […]
JUnit 4: AEM Sling Models Unit Test Constructor Injection Example
In this example, we will take a look at how we can mock Sling Model Constructor Injection dependencies for a JUnit 4 Unit test. Scenario: The Sling Model must expose either the PROD_URL or the DEAFULT_URL endpoint based on the run mode or request parameters; this is the requirement. The example below will demonstrate the […]
5 Popular Ways to Replicate a Page in AEM
In AEM 6+ there are many ways to accomplish the goal to “replicate” a page. This article will display 5 Popular Ways to Replicate a Page in AEM. At the end of this article, you should be able to “replicate” a page using different methods within AEM. Quick Links: Touch UI – Site Console – […]
How many times is an AEM Component used in the JCR?
Can we detect and remove unused components from our codebase? Is this AEM component being used at all? How many times is my component used within my running AEM instance? These are the common questions we have when we are trying to figure out the number of use and the node-paths of the targeted searched […]
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 […]
Articles List View
Articles List View This is a list view of all the popular articles on sourcedcode.com to help you navigate to your needs quicker. I hope this will page will help you find what you need, faster and more efficient! OSGI OSGI R6 Configuration @AttributeDefinition Essentials Reference Guide How to Enable Configuration for OSGI Components with […]
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) […]
AEM Sling Models Injectors Service Ranking
When working on an AEM project, Sling Models provides several custom Sling Models injectors to aid injection of Sling objects, Sling object values, OSGI services, etc… While using the injectors within in Sling Models, how do injectors invoke in order? Injectors are invoked in order, of their service ranking, from lowest to highest. If you […]
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> […]
Caching Experience Fragment Techniques in AEM Sites 6.5
This article explains different techniques to handle cache invalidation with AEM experience fragments. This topic will cover some of the questions that have been asked: What are the most efficient ways to cache AEM Experience Fragments in AEM? What are different ways to cache AEM Experience Fragments in AEM? What are the caching strategies for […]
Strategy to Consider when Migrating a Large Amount of Assets into an AEM author Instance
One of my biggest strategies to consider when migrating a large number of assets to production live AEM author instance is to enable/disable the workflow launchers. Every time when a new asset is installed (via the package manager) or uploaded into AEM, the OOTB (out of the box) AEM workflow launchers will be triggered. During […]
How to enable/disable AEM Workflow Launchers
Adobe Experience Manager (AEM) Assets ships with a number of default workflows and media handlers to operate on assets. Examples of these operations are generating thumbnail renditions, parsing Microsoft word documents, asset metadata extraction, etc… During appropriate understanding, we may need to disable workflow launchers services; always remember to re-enable after disabling these services. Quick […]
JUnit 4: AEM Sling Models Unit Test Example Using wcm.io AEM Mocks
Creating new AEM components, we sometimes need backend logic to compute user requests with business logic. There are multiple ways of doing so, like using the Java-Use API or Javascript-Use API, but the most popular and best practice of writing business logic for an AEM component will be using Sling Models. This article will demonstrate […]
AEM Global Objects for Backend and Front-end Sightly (HTL) Development
While working on an AEM project, we can speed up the process of development by utilizing the global objects offered by AEM Framework. Quick Links Backend Example Front-end Examples Sightly/HTL & AEM Backend Objects Mapping 1. AEM Backend, an example of using global objects The global objects are accessible by OSGI’s dependency injection annotation; @inject. […]
How to install multiple packages in CRX/DE on a clean instance?
You are ready to ship your project packages and package-dependencies over to your customers. You have 7+ packages that need to be individually installed; installing 7 packages is manually is not the best approach, and it will take too long (imagine when there are 5 AEM instances that need to be configured). What is the […]
How to revert deployed packages in CRX/DE package manager?
In this tutorial, you will learn how to revert a deployed package in CRX/DE package manager. The package is uploaded into CRX/DE and not yet replicated. Visit CRX/DE Lite (http://localhost:4502/crx/packmgr/index.jsp) Locate the project package. Click on “more” (the drop-down on the right). Click on “uninstall” (this will ensure your AEM instance is back to what […]
How to deploy new releases manually on Staging and Production AEM environments?
There are many ways for deploying new releases to AEM staging and Production environments. In this tutorial, I will share with you my process for deploying new releases manually. I personally found this the safer way to deploy new releases because you can easily roll back versions, and you let AEM’s out of the box […]
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 […]
What is the AEM Apache Sling Referrer Filter OSGI configuration?
AEM “referrer not allowed” Out of the box, AEM denies all server names or hosts to make HTTP request to the respective running AEM publish/author instance. During a HTTP request made to the AEM publish/author, AEM checks the Referrer header configuration. If the referrer configured to allow the host(s), then AEM will full-fill the request, […]
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? […]