<?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: How can we populate a generic list in form of dropdown in search box on a  page? in Adobe Experience Manager Questions</title>
    <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-we-populate-a-generic-list-in-form-of-dropdown-in-search/m-p/462323#M133421</link>
    <description>&lt;P&gt;We want that list as a part of component on a page not as a part of dialog box. Any solutions for that specific use case?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Jul 2022 09:51:05 GMT</pubDate>
    <dc:creator>Manasi29</dc:creator>
    <dc:date>2022-07-22T09:51:05Z</dc:date>
    <item>
      <title>How can we populate a generic list in form of dropdown in search box on a  page?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-we-populate-a-generic-list-in-form-of-dropdown-in-search/m-p/462316#M133416</link>
      <description>&lt;P&gt;We are creating a generic list using ACS commons we want that list as a part of search box where the list will be represented as a dropdown whenever user clicks in the search box. What are the approaches we can use to achieve the functionality by retrieving the generic list data.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 09:05:20 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-we-populate-a-generic-list-in-form-of-dropdown-in-search/m-p/462316#M133416</guid>
      <dc:creator>Manasi29</dc:creator>
      <dc:date>2022-07-22T09:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can we populate a generic list in form of dropdown in search box on a  page?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-we-populate-a-generic-list-in-form-of-dropdown-in-search/m-p/462321#M133419</link>
      <description>&lt;P&gt;Create a data source out of the generic list.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 09:45:34 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-we-populate-a-generic-list-in-form-of-dropdown-in-search/m-p/462321#M133419</guid>
      <dc:creator>anika_agarwal</dc:creator>
      <dc:date>2022-07-22T09:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can we populate a generic list in form of dropdown in search box on a  page?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-we-populate-a-generic-list-in-form-of-dropdown-in-search/m-p/462323#M133421</link>
      <description>&lt;P&gt;We want that list as a part of component on a page not as a part of dialog box. Any solutions for that specific use case?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 09:51:05 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-we-populate-a-generic-list-in-form-of-dropdown-in-search/m-p/462323#M133421</guid>
      <dc:creator>Manasi29</dc:creator>
      <dc:date>2022-07-22T09:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: How can we populate a generic list in form of dropdown in search box on a  page?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-we-populate-a-generic-list-in-form-of-dropdown-in-search/m-p/462362#M133441</link>
      <description>&lt;P&gt;&lt;LI-USER uid="17526021"&gt;&lt;/LI-USER&gt;&amp;nbsp;To achieve this functionality you can create the sling model and within the sling model get the resource present in the location i.e.&amp;nbsp;&lt;SPAN&gt;/etc/acs-commons/lists. For getting the values from the resource present under the list you can leverage the Resource API.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;String resourcePath = "&lt;SPAN&gt;/etc/acs-commons/lists/&amp;lt;list-name&amp;gt;";&lt;/SPAN&gt;&lt;BR /&gt;Resource resource = resolver.getResource(resourcePath);&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;Once you get the resource you can create the list from the sling model and the same can be iterated in sightly&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&amp;lt;ul data-sly-list.myitem="${mymodel.myitems}" data-sly-unwrap&amp;gt;
  &amp;lt;li&amp;gt;${myitem.foo}&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;This way the component will be cached and the list will also be populated from the generic list created from the Generic List in ACS Commons.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hope this helps!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 13:14:22 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-we-populate-a-generic-list-in-form-of-dropdown-in-search/m-p/462362#M133441</guid>
      <dc:creator>shaileshbassi</dc:creator>
      <dc:date>2022-07-22T13:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: How can we populate a generic list in form of dropdown in search box on a  page?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-we-populate-a-generic-list-in-form-of-dropdown-in-search/m-p/462366#M133443</link>
      <description>&lt;P&gt;&lt;A href="https://adobe-consulting-services.github.io/acs-aem-commons/features/generic-lists/index.html" target="_blank"&gt;https://adobe-consulting-services.github.io/acs-aem-commons/features/generic-lists/index.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Check the API section. I feel this should help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Anika&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 13:17:28 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-we-populate-a-generic-list-in-form-of-dropdown-in-search/m-p/462366#M133443</guid>
      <dc:creator>anika_agarwal</dc:creator>
      <dc:date>2022-07-22T13:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can we populate a generic list in form of dropdown in search box on a  page?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-we-populate-a-generic-list-in-form-of-dropdown-in-search/m-p/462455#M133473</link>
      <description>&lt;P&gt;Sharing sample code , hope this will help you -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Acs commons generic list associated with Indian cities -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DEBAL_DAS_0-1658575329982.png" style="width: 400px;"&gt;&lt;img src="https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/43461iADBC6760FF962B9D/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="DEBAL_DAS_0-1658575329982.png" alt="DEBAL_DAS_0-1658575329982.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;2. Location of acs common generic list associated with Indian cities in AEM repository -&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;/etc/acs-commons/lists/cities/jcr:content/list&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&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_1-1658575419310.png" style="width: 400px;"&gt;&lt;img src="https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/43462iEE3CE1FBE791F74F/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="DEBAL_DAS_1-1658575419310.png" alt="DEBAL_DAS_1-1658575419310.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Below sling model is responsible to read generic list associated with Indian cities -&lt;/P&gt;
&lt;PRE&gt;package com.aem.demo.core.models;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

import javax.annotation.PostConstruct;

import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.SlingObject;

import com.drew.lang.annotations.NotNull;
import com.drew.lang.annotations.Nullable;

@Model(adaptables = Resource.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class City  {

    

    @SlingObject
    private ResourceResolver resourceResolver;

    private Map&amp;lt;String, String&amp;gt; citymap;
    
    
	@PostConstruct
    protected void init() {
    	@Nullable
		Resource resource = resourceResolver.getResource("/etc/acs-commons/lists/cities/jcr:content/list");
    	if (Objects.nonNull(resource)) {
    		citymap = new HashMap&amp;lt;String, String&amp;gt;();
    		@NotNull
			Iterable&amp;lt;Resource&amp;gt; children = resource.getChildren();
    		for (Resource childResource : children) {
    			
    			
				String title = childResource.getValueMap().get("jcr:title", String.class);
				
				String nodevalue = childResource.getValueMap().get("value", String.class);
				citymap.put(nodevalue, title);
				
			}
    		
    		
			
		}
    	
		
	}
	public Map&amp;lt;String, String&amp;gt; getCitymap() {
		return citymap;
	}

    
   }
&lt;/PRE&gt;
&lt;P&gt;4. AEM component with code a field with drop down options -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;APP&amp;lt;/br&amp;gt;




&amp;lt;label&amp;gt;Please select a City:&amp;lt;/label&amp;gt;
&amp;lt;input list="city-details" id="city-choice" name="city-choice" /&amp;gt;
&amp;lt;div data-sly-use.cmap="com.aem.demo.core.models.City"&amp;gt;
&amp;lt;datalist id="city-details"&amp;gt;
&amp;lt;sly data-sly-list="${cmap.citymap}"&amp;gt;
    &amp;lt;option value="${cmap.citymap[item]}"&amp;gt;
&amp;lt;/sly&amp;gt;    
&amp;lt;/datalist&amp;gt;

&amp;lt;/div&amp;gt;&lt;/PRE&gt;
&lt;P&gt;5. Final output -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DEBAL_DAS_2-1658575604051.png" style="width: 400px;"&gt;&lt;img src="https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/43463i84F83123497E61EE/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="DEBAL_DAS_2-1658575604051.png" alt="DEBAL_DAS_2-1658575604051.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jul 2022 11:27:16 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-we-populate-a-generic-list-in-form-of-dropdown-in-search/m-p/462455#M133473</guid>
      <dc:creator>DEBAL_DAS</dc:creator>
      <dc:date>2022-07-23T11:27:16Z</dc:date>
    </item>
  </channel>
</rss>

