Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Constructing drop down using sightly

Avatar

Level 3

Hi All,

 i want to construct a drop down using sightly, Drop down should be auto populated with child pages names. Can any one help me on this how to implement . I am new to AEM technology. 

1 Accepted Solution

Avatar

Correct answer by
Level 3

Implementation :

 

In OSGI bundle you can set like below:

public ValueMap getAllRegions(){          
           ValueMap regionMap = new ValueMapDecorator(new HashMap<String, Object>());
          for (ValueMap attributes: multiFieldAttrValues(dynamic values get it from some other service or properties file)) {
               logger.debug("Region::"+attributes.get("region").toString());
               regionMap.put(attributes.get("region").toString(), attributes.get("regionlink").toString()) ;    
              }

        return regionMap;
    }

 

In Sightly:


<div data-sly-use.regionselector="com.basco.aem.briggs.core.components.RegionSelector" data-sly-unwrap>
<select name="regionselector">
<div data-sly-list.valuemapKey="${regionselector.allRegions}" data-sly-unwrap>
   <option value="${regionselector.allRegions[valuemapKey]}">${valuemapKey}</option>
</div>
</select>

 

Thanks,
Venkatesham

View solution in original post

2 Replies

Avatar

Correct answer by
Level 3

Implementation :

 

In OSGI bundle you can set like below:

public ValueMap getAllRegions(){          
           ValueMap regionMap = new ValueMapDecorator(new HashMap<String, Object>());
          for (ValueMap attributes: multiFieldAttrValues(dynamic values get it from some other service or properties file)) {
               logger.debug("Region::"+attributes.get("region").toString());
               regionMap.put(attributes.get("region").toString(), attributes.get("regionlink").toString()) ;    
              }

        return regionMap;
    }

 

In Sightly:


<div data-sly-use.regionselector="com.basco.aem.briggs.core.components.RegionSelector" data-sly-unwrap>
<select name="regionselector">
<div data-sly-list.valuemapKey="${regionselector.allRegions}" data-sly-unwrap>
   <option value="${regionselector.allRegions[valuemapKey]}">${valuemapKey}</option>
</div>
</select>

 

Thanks,
Venkatesham

Avatar

Level 10

Hi,

Which version AEM you are using ?

Can you clear me on this, Do you want to populate drop values in dialog or you have HTML form on a page?