Sightly question: how to adapt a class with a path | Community
Skip to main content
Level 5
Jul 26, 2017 2:28 PM UTC
Solved

Sightly question: how to adapt a class with a path

In java code, I can do this:

Resource articleResource = resourceResolver.getResource("/somepath/for/article");
  Article article = articleResource.adaptTo(Article.class);

Can Sightly do the same? and how?

In AEM 6.3 with sling models.

Thanks.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
VeenaVikraman
VeenaVikramanAccepted solution
New Participant
Jul 26, 2017 2:43 PM UTC

Probably my answer would be yes. Try the below code

  Let me know if it doesn't work

Thanks

Veena

13 replies

VeenaVikraman
New Participant
Jul 26, 2017 3:39 PM UTC

I am not sure if that is possible, because as far as I could understand, data-sly-resource should refer a resource which will resolve using sling resolution principles . I am not sure if we can refer a page path and try to resolve it as a resource. May be feike_visser​ can help you in this

Thanks

Veena

Translate
BigT168Author
Level 5
Jul 26, 2017 2:46 PM UTC

That's what I am doing.

Probably I should ask if we can do this in the HTL code

data-sly-use or data-sly-resource?

Thanks for your response.

Translate
VeenaVikraman
VeenaVikramanAccepted solution
New Participant
Jul 26, 2017 2:43 PM UTC

Probably my answer would be yes. Try the below code

  Let me know if it doesn't work

Thanks

Veena

Translate