Views
Replies
Total Likes
What is your usecase. Injecting child resource is possible. Please refer to https://sling.apache.org/documentation/bundles/models.html
List injection for child resources works by injecting grand child resources (since Sling Models Impl 1.0.6). For example, the class
@Model(adaptables=Resource.class)public class MyModel {@Injectprivate List<Resource> addresses;}
Is suitable for a resource structure such as:
+- resource (being adapted)|+- addresses|+- address1|+- address2
In this case, the addresses
List
will contain address1
and address2
.
Views
Replies
Total Likes
For Sling Models - see these Apache docs:
https://sling.apache.org/documentation/bundles/models.html#custom-injectors
I have not seen too many examples of using Sling Models in AEM. I will determine if we have examples internally.
Views
Replies
Total Likes
What is your usecase. Injecting child resource is possible. Please refer to https://sling.apache.org/documentation/bundles/models.html
List injection for child resources works by injecting grand child resources (since Sling Models Impl 1.0.6). For example, the class
@Model(adaptables=Resource.class)public class MyModel {@Injectprivate List<Resource> addresses;}
Is suitable for a resource structure such as:
+- resource (being adapted)|+- addresses|+- address1|+- address2
In this case, the addresses
List
will contain address1
and address2
.
Views
Replies
Total Likes
Hi @kalyanar,
I would like to have a class that I would adapt from Page, and wanted that its children were already injected, to not need to call listChildren.
Thanks
Views
Replies
Total Likes
Views
Likes
Replies