I want to clear the current sessionscopes in my xpages application and reload them again. I have tried:
public Map<String, Object> sesScope;
this.sesScope = JSFUtil.getSessionScope();
clearMap(sesScope);
private void clearMap(Map<String, Object> map ){ // Get iterator for the keys
String methodName = new Object(){}.getClass().getEnclosingMethod().getName();
utils.printToConsole(this.getClass().getSimpleName().toString() + " " + methodName);
utils.printToConsole("-------before removing------");
utils.printToConsole(map.toString());
Set keyset = map.keySet();
Iterator itr = keyset.iterator();
while (itr.hasNext()) {
itr.next();
itr.remove();
}
utils.printToConsole("--------After removing-------");
utils.printToConsole(map.toString());
}
Somehow I can not simply say sesScope.clear() since that would result in an error:
java.lang.UnsupportedOperationException at com.sun.faces.context.BaseContextMap.clear(ExternalContextImpl.java:392)
How do I clear the sessionscope properly?
I do this to clear sessionScope:
for (final String key : JSFUtil.getSessionScope().keySet()) {
JSFUtil.getSessionScope().remove(key);
}