Menu

Showing posts with label Injection Strategy in AEM. Show all posts
Showing posts with label Injection Strategy in AEM. Show all posts

AEM Sling Model injection and annotation

In this article, we will understand what all are the ways to reading authored values of AEM component using sling model in AEM

Using ValueMapValue annotation of package org.apache.sling.models.annotations.injectorspecific

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
private String classStartDateLabel;

Using Inject annotation of package javax.inject


@Inject
@Via("resource")
@Optional
private String classStartDateLabel;


Getter method for this injection


public String getClassStartDateLabel() {
return classStartDateLabel;
}