Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Day 07 - Sling Models | AEM Community Blog Seeding

Community Manager
Community Manager


Day 07 - Sling Models by Redquark Blog


Howdy fellow developers 👋! In the last post, we learned basics of HTL and clientlibs. Both HTL and clientlibs are responsible for rendering an AEM component on the frontend. There are times where we need to perform complex business logic on the backend and AEM is no exception.

AEM uses the OSGi framework for its backend activities and as we know from part 2 of this developer series, we write our Java code in OSGi bundle and deploy it to AEM.

In this post, we will create a simple component and perform some business logic on it using Java and based on that we will render the output on the page. The Java code will reside in a special model class known as Sling Model.

Sling Models
Wouldn’t it be great if you have a direct way to map your JCR node properties to your model class? Say what? Yeah, of course, it would be 😎. Sling Models lets us do this in AEM.

Sling Models are “pure” POJOs which map Sling objects (resources, request objects etc.).

Since Sling Models are annotation-driven Plain Old Java Objects (POJOs), annotations are used a lot. They allow us to map resource properties, assign default values, inject OSGi services and much more.

Basic Usage
The most simplest form of using Sling Models is in which the class is annotated with @Model, and with one adaptable. The fields which need to be injected are annotated with @Inject.

Read Full Blog

Day 07 - Sling Models


Please use this thread to ask the related questions.


Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies