<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Writing Sling Models for Nested Multifields. in Adobe Experience Manager Questions</title>
    <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/writing-sling-models-for-nested-multifields/m-p/448790#M128523</link>
    <description>&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Apr 2022 04:51:12 GMT</pubDate>
    <dc:creator>Manasi29</dc:creator>
    <dc:date>2022-04-20T04:51:12Z</dc:date>
    <item>
      <title>Writing Sling Models for Nested Multifields.</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/writing-sling-models-for-nested-multifields/m-p/448704#M128492</link>
      <description>&lt;P&gt;How can I write a sling Model to display a nested multifield with an image field in one of the multifield?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 14:34:01 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/writing-sling-models-for-nested-multifields/m-p/448704#M128492</guid>
      <dc:creator>Manasi29</dc:creator>
      <dc:date>2022-04-19T14:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Sling Models for Nested Multifields.</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/writing-sling-models-for-nested-multifields/m-p/448714#M128495</link>
      <description>&lt;P&gt;You can refer&amp;nbsp;&lt;A href="https://blogs.perficient.com/2018/08/24/using-sling-models-with-nested-composite-mulitifields-in-aem-6-3/" target="_blank" rel="noopener"&gt;https://blogs.perficient.com/2018/08/24/using-sling-models-with-nested-composite-mulitifields-in-aem-6-3/&lt;/A&gt;&amp;nbsp;, I used the similar approach to manage pathbrowser (to select image) , text area( for description) and text field(title).&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2022 04:05:22 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/writing-sling-models-for-nested-multifields/m-p/448714#M128495</guid>
      <dc:creator>DEBAL_DAS</dc:creator>
      <dc:date>2022-04-20T04:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Sling Models for Nested Multifields.</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/writing-sling-models-for-nested-multifields/m-p/448761#M128516</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;LI-USER uid="17526021"&gt;&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use list of class as mentioned below for filed injectors&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;@Model(adaptables = {Resource.class}, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public interface CompaniesModel {
  @Inject
  List&amp;lt;Names&amp;gt; getNames(); // `getNames` corresponds to the multifield name="./names"
  /**
   * Names model
   * has a name and a list of first names
   */
  @Model(adaptables = Resource.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
  interface Names {
    @Inject
    String getFirstName();
  }
  /**
   * First Name model
   * 
   */
  @Model(adaptables = Resource.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
  interface Firstname {
    @Inject
    String getName();
  }
}&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 19:24:21 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/writing-sling-models-for-nested-multifields/m-p/448761#M128516</guid>
      <dc:creator>SantoshSai</dc:creator>
      <dc:date>2022-04-19T19:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Sling Models for Nested Multifields.</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/writing-sling-models-for-nested-multifields/m-p/448790#M128523</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2022 04:51:12 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/writing-sling-models-for-nested-multifields/m-p/448790#M128523</guid>
      <dc:creator>Manasi29</dc:creator>
      <dc:date>2022-04-20T04:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Sling Models for Nested Multifields.</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/writing-sling-models-for-nested-multifields/m-p/449505#M128773</link>
      <description>&lt;P&gt;Sample code for nested multifields-&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. &lt;STRONG&gt;Sling model -&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;PRE&gt;package com.aem.demo.core.models;

import java.util.List;
import javax.inject.Inject;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Model;

@Model(
	    adaptables = {Resource.class},
	    defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public interface CompaniesModel {
	@Inject
	  List&amp;lt;Company&amp;gt; getCompanies(); // the name `getCompanies` corresponds to the multifield name="./companies"
	  /**
	   * Company model
	   * has a name and a list of departments
	   */
	  @Model(adaptables = Resource.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
	  interface Company {
	    @Inject
	    String getName();
	    @Inject
	    List&amp;lt;Department&amp;gt; getDepartments(); // the name `getDepartments` corresponds to the multifield name="./departments"
	  }
	  /**
	   * Department model
	   * has a name and a manager
	   */
	  @Model(adaptables = Resource.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
	  interface Department {
	    @Inject
	    String getImage();
	    
	  }

}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. &lt;STRONG&gt;.context.xml associated with cq:dialog&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:primaryType="nt:unstructured"
    jcr:title="Companies"
    sling:resourceType="cq/gui/components/authoring/dialog"&amp;gt;
    &amp;lt;content
        jcr:primaryType="nt:unstructured"
        sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns"&amp;gt;
        &amp;lt;items jcr:primaryType="nt:unstructured"&amp;gt;
            &amp;lt;column
                jcr:primaryType="nt:unstructured"
                sling:resourceType="granite/ui/components/coral/foundation/container"&amp;gt;
                &amp;lt;items jcr:primaryType="nt:unstructured"&amp;gt;
                    &amp;lt;companies
                        jcr:primaryType="nt:unstructured"
                        sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
                        composite="{Boolean}true"
                        fieldDescription="Click 'Add Field' to add a new company."&amp;gt;
                        &amp;lt;field
                            jcr:primaryType="nt:unstructured"
                            sling:resourceType="granite/ui/components/coral/foundation/container"
                            name="./companies"&amp;gt;
                            &amp;lt;items jcr:primaryType="nt:unstructured"&amp;gt;
                                &amp;lt;name
                                    jcr:primaryType="nt:unstructured"
                                    sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
                                    fieldLabel="Comp. Name"
                                    name="name"/&amp;gt;
                                &amp;lt;departments
                                    jcr:primaryType="nt:unstructured"
                                    sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
                                    composite="{Boolean}true"
                                    fieldDescription="Click 'Add Field' to add a new department."
                                    fieldLabel="Departments"&amp;gt;
                                    &amp;lt;field
                                        jcr:primaryType="nt:unstructured"
                                        sling:resourceType="granite/ui/components/coral/foundation/container"
                                        name="./departments"&amp;gt;
                                        &amp;lt;items jcr:primaryType="nt:unstructured"&amp;gt;
                                            &amp;lt;image
                                                jcr:primaryType="nt:unstructured"
                                                sling:resourceType="granite/ui/components/coral/foundation/form/pathfield"
                                                fieldLabel="Image"
                                                name="image"
                                                rootPath="/content/dam/we-retail/en/people"/&amp;gt;
                                        &amp;lt;/items&amp;gt;
                                    &amp;lt;/field&amp;gt;
                                &amp;lt;/departments&amp;gt;
                            &amp;lt;/items&amp;gt;
                        &amp;lt;/field&amp;gt;
                    &amp;lt;/companies&amp;gt;
                &amp;lt;/items&amp;gt;
            &amp;lt;/column&amp;gt;
        &amp;lt;/items&amp;gt;
    &amp;lt;/content&amp;gt;
&amp;lt;/jcr:root&amp;gt;&lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3. htl code -&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&amp;lt;sly data-sly-use.companiesModel="com.aem.demo.core.models.CompaniesModel"/&amp;gt;
&amp;lt;sly data-sly-test.empty="${!companiesModel.companies}" /&amp;gt;
&amp;lt;div data-sly-test="${wcmmode.edit &amp;amp;&amp;amp; empty}" class="cq-placeholder" data-emptytext="${component.title}"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;sly data-sly-test="${!empty}"&amp;gt;
  &amp;lt;div&amp;gt;
      &amp;lt;ul data-sly-list.company="${companiesModel.companies}"&amp;gt;
        &amp;lt;li&amp;gt;${company.name}
          &amp;lt;ul data-sly-list.department="${company.departments}"&amp;gt;
            &amp;lt;li&amp;gt;
               &amp;lt;img src="${department.image}" width="300" height="300"&amp;gt;&amp;lt;/br&amp;gt;
            &amp;lt;/li&amp;gt;
          &amp;lt;/ul&amp;gt;
        &amp;lt;/li&amp;gt;
      &amp;lt;/ul&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/sly&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;4.&amp;nbsp; Author's entries using touch ui dialog and rendered output -&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DEBAL_DAS_0-1650791505603.png" style="width: 400px;"&gt;&lt;img src="https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/40420i14EC89BC7CE5E0A3/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="DEBAL_DAS_0-1650791505603.png" alt="DEBAL_DAS_0-1650791505603.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DEBAL_DAS_1-1650791514359.png" style="width: 400px;"&gt;&lt;img src="https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/40421i6094C83798AC89B1/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="DEBAL_DAS_1-1650791514359.png" alt="DEBAL_DAS_1-1650791514359.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DEBAL_DAS_2-1650791532184.png" style="width: 400px;"&gt;&lt;img src="https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/40422i640EABAD77D40546/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="DEBAL_DAS_2-1650791532184.png" alt="DEBAL_DAS_2-1650791532184.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DEBAL_DAS_3-1650791541797.png" style="width: 400px;"&gt;&lt;img src="https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/40423i2E79DB3F83E528F3/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="DEBAL_DAS_3-1650791541797.png" alt="DEBAL_DAS_3-1650791541797.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Apr 2022 09:13:09 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/writing-sling-models-for-nested-multifields/m-p/449505#M128773</guid>
      <dc:creator>DEBAL_DAS</dc:creator>
      <dc:date>2022-04-24T09:13:09Z</dc:date>
    </item>
  </channel>
</rss>

