I am wanting to generate some "data-attributes" and "values" using a multifield in the dailog.[Ex: data-sample-name = name] How to access those authored values in HTL under single tag?
I tried this solution: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/output-html-attribute-name...
but my map from java does not work.
Any idea?
Thanks,
Kiran Vedantam.
Solved! Go to Solution.
Hi @Kiran_Vedantam,
Below works fine. Cross check the way you populate the Map.
If you still face issues, share the source of Map/ multifield content structure.
@Getter
public Map<String, String> requestAttrMap = new HashMap<>();
In @PostConstruct method, populate the map
requestAttrMap.put("attribute01", "Attr Value 01");
requestAttrMap.put("attribute02", "Attr Value 02");
requestAttrMap.put("attribute03", "Attr Value 03");
In HTL, access like you would access any getter from Sling Model
<div data-sly-use.obj="${'com.aem.demoproject.core.models.ChildResourceCheckModel'> <!--/* Data attributes */--> <div data-sly-attribute=${obj.requestAttrMap}> <p>Data Attributes</p> </div> </div>
Update :
Hi @Kiran_Vedantam,
Below works fine. Cross check the way you populate the Map.
If you still face issues, share the source of Map/ multifield content structure.
@Getter
public Map<String, String> requestAttrMap = new HashMap<>();
In @PostConstruct method, populate the map
requestAttrMap.put("attribute01", "Attr Value 01");
requestAttrMap.put("attribute02", "Attr Value 02");
requestAttrMap.put("attribute03", "Attr Value 03");
In HTL, access like you would access any getter from Sling Model
<div data-sly-use.obj="${'com.aem.demoproject.core.models.ChildResourceCheckModel'> <!--/* Data attributes */--> <div data-sly-attribute=${obj.requestAttrMap}> <p>Data Attributes</p> </div> </div>
Update :
Views
Likes
Replies