Which two approaches correctly read the value of testParam in Sling model?

Review the following HTL code snippet:

<div data-sly-

use.testComponent=’${com.adobe.core.models.TestComponent’@ testParam=’testValue’}’></div>

Which two approaches correctly read the value of testParam in Sling model? (Choose two.)
A . @lnject @Sourcef’request-aItribuIes") @Named{"testParam’)
B . @RequestAttribute(name = "leslParam")
C . @lnject(name = ‘testParam’)
D . @lnjecT @Prop("testParam")

Answer: BC

Explanation:

In Sling Models, annotations are used to map request parameters, attributes, and properties to fields in Java classes. When an HTL script passes parameters to a Sling Model, the Sling Model can use annotations to access these parameters.

Option B uses the @RequestAttribute annotation which allows the Sling Model to retrieve an attribute that has been set on the Sling HTTP request object. This is a valid approach to read the ‘testParam’ if it has been set as a request attribute.

Option C uses the @Inject annotation with the name attribute specifying the name of the parameter to inject. This is another valid approach to read the ‘testParam’ from the request.

Option A is incorrect because @Named is not the correct annotation for retrieving request attributes or parameters.

Option D is incorrect because there is no @Prop annotation in Sling Models; it’s likely confused with the @Property annotation which is not the correct one for this context either.

Latest AD0-E123 Dumps Valid Version with 50 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments