Inject Child Pages using Sling Models | Adobe Higher Education
Skip to main content
Dieses Thema wurde für Antworten geschlossen.
Beste Antwort von gopalKa

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.

3 Antworten

smacdonald2008
Level 10
October 16, 2015

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. 

gopalKaAdobe EmployeeAntwort
Adobe Employee
October 16, 2015

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.

francisco_ribei
Level 6
October 16, 2015

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