In this blog­post I want to show you some code around a new way you can change resources via the ResourceResolver

In the new ResourceRe­solver there are meth­ods avail­able to create/update/delete your Resources.

This is now quite a straight­for­ward way, I will demon­strate this via some basic code sam­ples.
Chang­ing a resource

Here a code sam­ple how to add / change a prop­erty on an exist­ing resource. Via the Mod­i­fi­abl­e­Val­ueMap you can mod­ify the properties.

ResourceRe­solver resourceRe­solver = getRe­sourceRe­solver();
Resource resource = getSlingRequest().getResource();

Mod­i­fi­abl­e­Val­ueMap mvp = resource.adaptTo(ModifiableValueMap.class);

// adding and chang­ing a prop­erty
if ( mvp.containsKey(“test”)) {
String prop­Value = mvp.get(“test”, String.class);
mvp.put(“test”, prop­Value + “1”);
} else {
mvp.put(“test”, “test”);

Cre­ate / Delete a resource

Via the meth­ods cre­ate() / delete() you can cre­ate and delete a new resource.

ResourceRe­solver resourceRe­solver = getRe­sourceRe­solver();
Resource resource = getSlingRequest().getResource();

// adding and remov­ing a child node
if ( resource.getChild(“person”) == null ) {
Map props = new HashMap();
props.put(“firstname”, “feike”);
props.put(“lastname”, “visser”);

Resource newRe­source = resourceResolver.create(resource, “per­son”, props);
} else {

Sav­ing / Revert­ing changes

Via the meth­ods .com­mit() and .revert() you can either save or roll­back the changes.

if ( resourceResolver.hasChanges() ) {





Kelly Almon
Kelly Almon

This is an interesting topic. I think it should be said that customer expectations may have changed - but only to match their desires. Whereas before customers didn't see the alternatives available to the fee-laden, single channel, bank-driven communication, they now see how other industries are engaging with their customers in more meaningful ways and are asking why financial services aren't doing so as well. I definitely agree with your last paragraph - imperative is the right word. Financial services is incredibly important on a very personal level, so why are financial organizations not engaging with their customers on a personal level, through the individual's choice of channels.