QuestionQ31

VerifiedGiven a scenario, identify how to implement Sling Models and HTL

A snippet throws an exception at runtime:

Question Image

What should the developer add to fix it?

Explanation

The current Page is request-context data provided through Sling bindings. A Sling Model adapted only from Resource lacks that request context, so its required Page injection cannot be resolved. Declaring SlingHttpServletRequest.class as an adaptable enables request-based model adaptation and provides the needed bindings.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!