Wednesday, 15 June 2016

Working with Sling Models in Adobe Experience Manager 6.2

You can work with Sling Models when developing with Adobe Experience Manager (AEM) 6.2. That is, when developing an AEM project, you can define a model object (a Java object) and map that object to Sling resources. For more information, see Sling Models.

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;


@Model(adaptables = Resource.class)
public class UserInfo {
    private String firstName;
    private String lastName;
    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. 

Adobe Digital Marketing Community

Join the Adobe Digital Marketing Community. Start by clicking this banner

I (Scott Macdonald) am a Senior Digital Marketing Community Manager at Adobe Systems with over 18 years in the high tech industry. I am also a programmer with knowledge in Java, JavaScript, C#,C++, HTML, XML and ActionScript. If  you would like to see more CQ or other Adobe Digital Marketing end to end articles like this, then leave a comment and let me know what content you would like to see.

TwitterFollow the Digital Marketing Customer Care team on Twitter @AdobeMktgCare.
TwitterFollow me on Twitter @smac2020

No comments:

Post a Comment