Skip to main content
Aug 27, 2019 6:11 PM UTC
Solved

sling model choice

Hi,

I have created sling model for the component.

While creating the sling model i need to specify the

@Model(adaptables = Resource.class) or @Model(adaptables=slinghttpservletrequest)

On what bases we have to select the adaptables.

I am new to AEM Kindly explain in detail to understand the concept.

Regards

Kusuma M

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
zonrocAccepted solution
Level 3
Aug 31, 2019 6:34 PM UTC

If you want to read the values that an author enters into a component dialog, then:

@Model(adaptables = Resource.class)

will be fine. For more on working with Sling Models on 6.5 - see this article -- Building Experience Manager 6.5 Components using Granite/Coral Resource Types

4 replies

zonrocAccepted solution
Level 3
Aug 31, 2019 6:34 PM UTC

If you want to read the values that an author enters into a component dialog, then:

@Model(adaptables = Resource.class)

will be fine. For more on working with Sling Models on 6.5 - see this article -- Building Experience Manager 6.5 Components using Granite/Coral Resource Types

Translate
Umesh_Sondhi
Level 4
Aug 30, 2019 9:36 AM UTC

Hi kusumam24182037

You can refer to this two link ,it has detail description for the same and videos too.

AEM Developer Learning : Deep Dive on Sling Models in AEM6.3 : Part-1

AEM Developer Learning : Deep Dive on Sling Model in AEM 6.3 : Part-2

Happy to help !

Thanks

Translate
rampai
Level 1
Aug 28, 2019 6:03 AM UTC

Hi kusumam24182037​,

The above links should clear your understanding.

Adapting to a SlingHttpServletRequest gives you more options to manipulate resources in general.

Moreover you can even access request params if you do so.

Adapting to a resource can be done when you just need resource properties and there is not much to do with the request.

Please check if my answer here helps.

Regards,

Ram

Translate
Employee
Aug 28, 2019 2:27 AM UTC