Posts

Showing posts from August, 2021

Use cases of ModifiableValueMap in AEM

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(&q