top of page
  • Writer's pictureHeena

Adaptables parameter in Sling Model | AEM


Confused about when to pass what class in adaptables parameter to the @Model annotation in an AEM Sling Model?


@Model annotation

When defining a Sling Model class, the adaptables parameter to the @Model annotation is mostly determined by the injectors being used in it.



What class you passed totally depends on what you want out of the model. If you want to fetch values from for example the authored values, which is in turn a resource, you will pass Resource.class. Whereas, if you want to fetch request based values, you will pass SlingHttpServletRequest.class to adaptables.



For example, if the Sling Model only uses @ValueMapValue, then adaptable will be set to Resource.class. Whereas if it uses for eg. @ScriptVariable/@RequestAttribute then adaptable should be SlingHttpServletRequest.class.


Also, you can pass one or more values to adaptables parameter as follows:

How to pass one or more values to adaptables parameter

158 views

Related Posts

See All
bottom of page