A Sling Model is implemented as an OSGi bundle. A Java class located in the OSGi bundle is annotated with @Model and the adaptable class (for example, @Model(adaptables = Resource.class). The data members (Fields) use @Inject annotations. These data members map to node properties.
Consider the following Java class named UserInfo.
package SlingModel62.core;
import javax.inject.Inject;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
@Model(adaptables = Resource.class)
public class UserInfo {
@Inject
private String firstName;
@Inject
private String lastName;
@Inject
private String technology;
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public String getTechnology() {
return technology;
}
}
This class can be mapped to nodes in the AEM JCR. You can create an AEM application that uses Sling Mapping to display node properties.

This development article walks you through how to use Sling Models in AEM 6.2.
To read this development article, click https://helpx.adobe.com/experience-manager/using/slingmodel_62.html.
No comments:
Post a Comment
If you have any doubts or questions, please let us know.