Skip to content

Instantly share code, notes, and snippets.

@VivekSaha
VivekSaha / TextareaSampleComponentModel.java
Created September 30, 2025 19:21
AEM - Textarea Component using Sling Model
//C:\aem-project\aemgeeks\core\src\main\java\com\aemgeeks\core\models\TextareaSampleComponentModel.java
package com.aemgeeks.core.models;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Model;
import javax.inject.Inject;
@Model(adaptables = Resource.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@VivekSaha
VivekSaha / NumberfieldSampleComponentModel.java
Created September 30, 2025 14:41
AEM - Number Field Component using Sling Model
//C:\aem-project\aemgeeks\core\src\main\java\com\aemgeeks\core\models\NumberfieldSampleComponentModel.java
package com.aemgeeks.core.models;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Model;
import javax.inject.Inject;
@Model(adaptables = Resource.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@VivekSaha
VivekSaha / TextfieldSampleComponentModel.java
Created September 30, 2025 13:24
AEM - Text Field Component using Sling Model
//C:\aem-project\aemgeeks\core\src\main\java\com\aemgeeks\core\models\TextfieldSampleComponentModel.java
package com.aemgeeks.core.models;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Model;
import javax.inject.Inject;
@VivekSaha
VivekSaha / custom-component.html
Created September 30, 2025 12:16
AEM - Custom Component with Dialog CRXD
<sly data-sly-use.templates="core/wcm/components/commons/v1/templates.html"/>
<div>
<h2>${properties.yourname}</h2>
<p>${properties.youremail}</p>
<p>${properties.yourage}</p>
<p>${properties.yourcontactno}</p>
</div>
<sly data-sly-call="${templates.placeholder @ isEmpty = !properties.productTitle}" />
@VivekSaha
VivekSaha / custom-component.txt
Created September 30, 2025 07:57
AEM - Custom component with dialog in Code
Custom component with dialog:- Code
Step 1 - Create component folder "productdetails"
e.g:- ui.apps\src\main\content\jcr_root\apps\aemgeeks\components\productdetails
Step 2 - Create a ".content.xml" file
e.g:- ui.apps\src\main\content\jcr_root\apps\aemgeeks\components\productdetails\.content.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
@VivekSaha
VivekSaha / custom-component.txt
Created September 29, 2025 18:49
AEM - Custom component without dialog Code level
Custom component without dialog:- Code level
Step 1 - Create component folder "productdetails"
e.g:- ui.apps\src\main\content\jcr_root\apps\aemgeeks\components\productdetails
Step 2 - Create a ".content.xml" file
e.g:- ui.apps\src\main\content\jcr_root\apps\aemgeeks\components\productdetails\.content.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
@VivekSaha
VivekSaha / custom-component.txt
Created September 29, 2025 18:35
AEM - Custom component without dialog CRXDE
Custom component without dialog:- CRXDE
Step 1: Create Node Title "Product Details" & Type "cq:Component".
Add properties
jcr:primaryType="cq:Component"
jcr:title="Product Details"
componentGroup="AEM Geeks - Content"
Step 2:- Create .html file "productDetails.html" for render in UI.
@VivekSaha
VivekSaha / aem-template-type.txt
Created September 29, 2025 14:52
AEM Create Template Type
To create new page template type:-
ui.content\src\main\content\jcr_root\conf\aemgeeks\settings\wcm\template-types
Here, I need to create a new folder or clone the existing Page folder.
ui.content\src\main\content\jcr_root\conf\aemgeeks\settings\wcm\template-types\newpage
Update .content.xml
ui.content\src\main\content\jcr_root\conf\aemgeeks\settings\wcm\template-types\newpage\.content.xml
@VivekSaha
VivekSaha / aem-debug.txt
Created September 29, 2025 13:53
AEM Debug .js & .java
https://experienceleague.adobe.com/en/docs/experience-manager-learn/cloud-service/debugging/debugging-aem-sdk/remote-debugging
AEM Java code debug:-
Start AEM in debug mode run command
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar aem-author-p4502.jar
or
Create a .bat file (debug-run.bat) in side of the author instance and put the script inside of the file.
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar aem-author-p4502.jar
To run the AEM in debug just double click on the .bat file.
@VivekSaha
VivekSaha / sightly-attribute.txt
Created September 29, 2025 13:38
AEM Sightly Attributes
These are HTL (Sightly) block statements used in AEM templates to control rendering logic.
1. data-sly-include:- To include static or dynamic HTML/HTL snippet into your template.
<sly data-sly-include="footer.html"></sly>
Useful when reusing a template fragment.
2. data-sly-use: To import/use a Java class, Sling Model, JS or JavaScript object in your HTL file.
<sly data-sly-use.model="com.example.core.models.HelloWorldModel"/>
<p>${model.message}</p>
Useful for binding backend logic (Sling Models/Use API) to the UI.