Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

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




Creating Your First Sample Component Using Sling Model by Aasishjain


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


Please use this thread to ask the related questions.

Kautuk Sahni

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

0 Replies