Exam AD0-E123 Topic 2 Question 4 Discussion
Actual exam question for Adobe's AD0-E123 exam
Question #: 4
Topic #: 2
Question #: 4
Topic #: 2
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.)
<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.)
Suggested Answer: B,C Vote an answer
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@RequestAttributeannotation 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@Injectannotation with thenameattribute 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@Namedis not the correct annotation for retrieving request attributes or parameters.
Option D is incorrect because there is no@Propannotation in Sling Models; it's likely confused with the
@Propertyannotation which is not the correct one for this context either.
Option B uses the@RequestAttributeannotation 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@Injectannotation with thenameattribute 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@Namedis not the correct annotation for retrieving request attributes or parameters.
Option D is incorrect because there is no@Propannotation in Sling Models; it's likely confused with the
@Propertyannotation which is not the correct one for this context either.
by Raymond at Dec 16, 2025, 09:35 PM
0
0
0
10
Comments
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Report Comment
Commenting
You can sign-up / login (it's free).