what is the difference between @ChildResourceFromRequest and @ChildResource with examples? | Community
Skip to main content
New Participant
April 25, 2022
Solved

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

  • April 25, 2022
  • 2 replies
  • 2187 views

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.
Best answer by MayurSatav

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

2 replies

MayurSatav
MayurSatavAccepted solution
New Participant
April 25, 2022

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

New Participant
April 26, 2022

thank you for reply ,

it helped