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
BedrockMission!

Learn More

View all

Sign in to view all badges

Creating Your First Sample Component Using Sling Model | AEM Community Blog Seeding

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,198 likes

Total Posts

6,369 posts

Correct Reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,198 likes

Total Posts

6,369 posts

Correct Reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

22-02-2021

BlogImage.jpg

Creating Your First Sample Component Using Sling Model by Aasishjain

Abstract

Sling Models allows us to map resource properties, assign default values, inject OSGi services and much more.
For AEM 6.3+, we don’t need to install the Sling Models API and Implementation bundle. But we need to make sure that the bundle version of Sling Models API present in the AEM matches with the version declared in the POM file.

Let us understand the code of the class. The class is annotated with @Model and the adaptable class.
Fields which need to be injected are annotated with @Inject.
@PostConstruct annotation can be used to add methods which are invoked upon completion of all injections.
@Injectfields are assumed to be required. To mark them as optional, we use @Optional.If a majority of @Inject fields are optional, it is possible to change the default injection strategy by using adding defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL to the @Modelannotation

Read Full Blog

Creating Your First Sample Component Using Sling Model

Q&A

Please use this thread to ask the related questions.

AEM AEMEBlogSeeding Experience Manager