Skip to main content
Dinu_Arya
Level 6
Jun 15, 2016 11:45 AM UTC
Solved

Sling Modles - Specifying an Alternate Adapter Class

Hi Team,

I tried the below code in sling models but I got error for declaring adapters -

@Model(adaptables = Resource.class, adapters = MyModel.class)
public class MySlingModel {
}

I'm using the below dependencies -

    <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.models.api</artifactId>
            <version>1.1.0</version>
            <scope>provided</scope>
        </dependency>

Earlier I used for the version 1.0.0. But it is not working. I'm unable to use adapters.

Can you pls help me in this?

Thanks,

AryA.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
AnkurAhlawat-1
AnkurAhlawat-1Accepted solution
Level 6
Jun 29, 2016 6:56 AM UTC

You have used @Model incorrectly.

There is no way to create a Sling Model from more than one adaptable, Your class can adapt to multiple means it can adapt to different classes but at one point of time only one.

Read more about How to use Sling Model with Sightly in AEM

regards,

Ankur Ahlawat

AEM CQ5 Tutorials

5 replies

smacdonald2008
Level 10
Jun 15, 2016 1:03 PM UTC

What version of AEM are you using? 

Translate
smacdonald2008
Level 10
Jun 15, 2016 1:14 PM UTC

We are going to release a new AEM 6.2 SLing Model Article. I will post soon. 

Translate
kautuk_sahni
Level 9
Jun 16, 2016 6:03 AM UTC

Hi 

Please refer to :- https://helpx.adobe.com/experience-manager/using/sling_models.html

//

Adding following dependency to the pom.xml help overcoming this problem:

<dependency>

    <groupId>org.apache.geronimo.specs</groupId>

    <artifactId>geronimo-atinject_1.0_spec</artifactId>

    <version>1.0</version> <scope>provided</scope>

</dependency>

Reference :- Go to depfinder:- http://localhost:4502/system/console/depfinder  [to find out dependency]

Please let me know, what exactly is the error coming?

PS:- Please add the dependency mentioned. Even the article Link mentioned by me is missing with this dependency, so add it and run it.

Thanks and Regards

Kautuk Sahni 

Translate
Kautuk Sahni
kautuk_sahni
Level 9
Jun 28, 2016 9:37 AM UTC

smacdonald2008 wrote...

We are going to release a new AEM 6.2 SLing Model Article. I will post soon. 

 

Article Released:- https://helpx.adobe.com/experience-manager/using/slingmodel_62.html

~kautuk

Translate
Kautuk Sahni
AnkurAhlawat-1
AnkurAhlawat-1Accepted solution
Level 6
Jun 29, 2016 6:56 AM UTC

You have used @Model incorrectly.

There is no way to create a Sling Model from more than one adaptable, Your class can adapt to multiple means it can adapt to different classes but at one point of time only one.

Read more about How to use Sling Model with Sightly in AEM

regards,

Ankur Ahlawat

AEM CQ5 Tutorials

Translate