Skip to main content
Level 4
Apr 25, 2022 8:44 AM UTC
Solved

what is the difference between @ChildResourceFromRequest and @ChildResource with examples?

Hi, may I know,

what is the difference between @ChildResourceFromRequest and @ChildResource with examples

Thank you

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
MayurSatav
MayurSatavAccepted solution
New Participant
Apr 25, 2022 12:14 PM UTC

Hi @rahul234dabas ,

 

let me give you a basic understanding of your doubt.

When we try to inject a resource as @ChildResource, it loses the context of SlingHttpServletRequest. Hence we use @ChildResourceFromRequest instead @ChildResource. The @ChildResourceFromRequest is found in the ACS AEM Commons package. In @ChildResourceFromRequest, it uses a mock request object pointed to the resource path as the adaptable, Which allows the sling model to reference the request. But it fails to inject via the standard @ChildResource injector. 

 

Thanks

3 replies

MayurSatav
MayurSatavAccepted solution
New Participant
Apr 25, 2022 12:14 PM UTC

Hi @rahul234dabas ,

 

let me give you a basic understanding of your doubt.

When we try to inject a resource as @ChildResource, it loses the context of SlingHttpServletRequest. Hence we use @ChildResourceFromRequest instead @ChildResource. The @ChildResourceFromRequest is found in the ACS AEM Commons package. In @ChildResourceFromRequest, it uses a mock request object pointed to the resource path as the adaptable, Which allows the sling model to reference the request. But it fails to inject via the standard @ChildResource injector. 

 

Thanks

Translate
Level 4
Apr 26, 2022 5:32 AM UTC

thank you for reply ,

it helped

Translate