Expand my Community achievements bar.

SOLVED

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

Avatar

Level 5

Hi, may I know,

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

Thank you

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

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