QuestionQ38

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

A custom component contains one dialog field:

Question Image

A developer must implement a Sling Model that performs business logic on the authored value. The developer writes the following HTL snippet:

Question Image

Which two implementations support this HTL snippet?

Choose two
Explanation

The authored dialog value is stored in the component resource as the title property. A SlingHttpServletRequest model can inject that property through @Via("resource"), and a Resource model can inject it directly with @ValueMapValue named title. Both implementations invoke their message-building logic with @PostConstruct and expose getMessageText() for HTL. @ScriptVariable injects a Sling binding rather than a resource property, and an unannotated init() method is not a post-construction lifecycle method.

Learn more

Community Discussion

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