Expand my Community achievements bar.

Building AEM components with Sling models | AEM Community Blog Seeding

Avatar

Administrator

BlogImage.jpg

Building AEM components with Sling models by Exadel

Abstract

Generally, contemporary AEM components are based on AEM Sling models. The pattern that allows you to use Sling models in AEM is called injection. We create fields, attach Sling injector annotations to them, add getters and, thus, receive data-filled objects.

Many developers can hardly imagine how diversified the range of injectors and corresponding AEM annotations is. You can come across the standard Sling annotations. More annotations are added in the well-known ACS AEM Commons package. In addition, you can create your own custom injectors with AEM annotations.

Concerning which injector annotations to use, you might think that @Inject annotation is the remedy for all injection cases since multiple tutorials tell you so. But, that’s not quite true, and, using @Inject, in particular, is less favorable. You can find evidence in the code provided by Adobe Consulting Services, or in this article offering a deep dive into Sling models.

The Exadel Marketing Technology Team is successfully utilizing multiple AEM annotations from Apache Sling. We’ve learned to combine annotations coming from Sling with the annotations from the Exadel Authoring Kit, as well as Lombok annotations necessary for generating accessors for Java class fields. The combinations we create help us reduce boilerplate code. You can visualize things better with the examples below.

The correlation between naming
The Exadel Authoring Kit’s annotations such as @DialogField, @TextField, and Apache Sling annotations such as @ValueMapValue, @Default, even Lombok’s annotations such as @Getter can be put onto the same entities and work together successfully.

Read Full Blog

Building AEM components with Sling models

Q&A

Please use this thread to ask the related questions.



Kautuk Sahni
0 Replies