Inject child nodes that were created by eaem-nested="NODE_STORE" in a Sling Model | Community
Skip to main content
New Member
June 26, 2017

Inject child nodes that were created by eaem-nested="NODE_STORE" in a Sling Model

  • June 26, 2017
  • 1 reply
  • 4809 views

Hi guys,

I have a dialog that has a multifield with a complex object type identified by the snippet below:

<foo

    jcr:primaryType="nt:unstructured"

    sling:resourceType="granite/ui/components/foundation/form/multifield"

    fieldLabel="Foo">

    <field

        jcr:primaryType="nt:unstructured"

        sling:resourceType="granite/ui/components/foundation/form/fieldset"

        eaem-nested="NODE_STORE"

        name="./foo">

        <layout

            jcr:primaryType="nt:unstructured"

            sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"

            method="absolute"/>

        <items jcr:primaryType="nt:unstructured">

            <column

                jcr:primaryType="nt:unstructured"

                sling:resourceType="granite/ui/components/foundation/container">

                <items jcr:primaryType="nt:unstructured">

                    <bar1

                        jcr:primaryType="nt:unstructured"

                        sling:resourceType="granite/ui/components/foundation/form/textfield"

                        fieldLabel="Bar1"

                        name="./bar1"/>                   

                    <bar2

                        jcr:primaryType="nt:unstructured"

                        sling:resourceType="granite/ui/components/foundation/form/textfield"

                        fieldLabel="Bar2"

                        name="./bar2"/>

                    <bar3

                        jcr:primaryType="nt:unstructured"

                        sling:resourceType="granite/ui/components/foundation/form/textfield"

                        fieldLabel="Bar3"

                        name="./bar3"/>

                </items>

            </column>

        </items>

    </field>

</foo>

I've used  eaem-nested="NODE_STORE" to generate a new node per multifield entry in order to keep things organized.

The structure in the repository looks like this:

 

I'm trying to inject this in my Sling Model but without success. I've already tried the examples below but without success.

@Inject

private List<Foo> foo; // Null element

@Inject

private List<Resource> foo; // List with only one element (i.e. foo child node)

@ChildResource

private List<Resource> foo; // List with only one element (i.e. foo child node)

Any ideas on how to inject this type of structures properly?

Thanks!

Diogo

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

VeenaVikraman
Community Advisor
Community Advisor
June 27, 2017

Hi diogo

   If my understanding is correct, you are trying to fetch the foo node ? In that case the best solution is to inject it as resource . PLease find below Sample snippet

               Please note that foo should match the node name of your resource. Since I see the node structure is this

            I have named the variable as foo.

          Also, if you don't expect this node to be present always , just add @optional annotation after @inject

I assume this is what you are looking for Sightly + Sling Models Amazing Combination – Rahul Mengji

Thanks

Veena

Feike_Visser1
Adobe Employee
Adobe Employee
June 28, 2017

Can you share the node-structure that you have? That might be easier to see what you want.

New Member
June 28, 2017

Thanks for your answer.

The structure is already there. Which other detail do you need?