public void updateId(String oldId, String newId) {
        Map<String, String> events = cspState.getEventHandlers().remove(oldId);
        if (events != null && !events.isEmpty()) {
            for (Map.Entry<String, String> entry : events.entrySet()) {
                String oldValue = entry.getValue();
                // replace 'id=' and 'source:' values
                String newValue = oldValue.replaceAll("\\sid=\"" + oldId + "\"", " id=\"" + newId + "\"");
                newValue = newValue.replaceAll("source:\"" + oldId + "\"", " source:\"" + newId + "\"");
                entry.setValue(newValue);
            }
            CspState cspState = this.cspState;
            cspState.getEventHandlers().put(newId, events);
        }
    }
Special scenario where for indexed id's we need to replace the old id with new one.

@param oldId the old id
@param newId the new id
primefaces/src/main/java/org/primefaces/csp/CspResponseWriter.java