Expand my Community achievements bar.

Join expert-led, customer-led sessions on Adobe Experience Manager Assets on August 20th at our Skill Exchange.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

Use cases of ModifiableValueMap in AEM | AEM Community Blog Seeding

Avatar

Administrator

BlogImage.jpg

Use cases of ModifiableValueMap in AEM by aem-ti2fap blogspot

Abstract

The ModifiableValueMap is an extension of the ValueMap which allows to modify and persist properties.
All changes to this map are stored in the transient layer of the resource resolver or more precisely in the transient layer of the resource provider managing this resource.
Use cases in AEM ::

Mandatory step -
1. Get the resource resolver.
2. Get ModifiableValueMap interface -
ModifiableValueMap mvp = resolver.adaptTo(ModifiableValueMap.class);

1. Get SINGLE value property of a node:
String value = mvp.get("multivalue", String.class);

2. Get MULTI value property of a node:
String[] value = mvp.get("multivalue", String[].class);

3. Add SINGLE value property to a node:
String val = "single";
a. mvp.put("singlevalue", val);
b. mvp.putIfAbsent("singlevalue", val);


4. Add MULTI value property to a node:
String[] val = {"test1","test2"};
mvp.put("multivalue", val);

5. Add MULTIPLE properties to a node:
Map<String, String[]> map = new HashMap<>();
map.put("prop1", val1);
map.put("prop2", val2);
mvp.putAll(mapp);

P.S.- Perform resolver.commit() after put operation and do resolver.close() after completing all resource resolver related operations.

Read Full Blog

Use cases of ModifiableValueMap in AEM

Q&A

Please use this thread to ask the related questions.



Kautuk Sahni
0 Replies