Hi
I've written a method to clear a request scoped bean from extended request scope and I was wondering if I could get feedback on if it will work for others. I am using it to control the state of certain pages in my workflow allowing me to have some pages work as if they are not under extended request scope.
Code:
protected void removeIceFacesExtendedRequestScopeBean(String managedBeanName) {
Object bean = getBean(managedBeanName);
if (bean instanceof DisposableBean) {
try {
((DisposableBean) bean).dispose();
} catch (Exception e) {
log("Failed to properly dispose " + bean + " bean.", e);
}
}
setBean(managedBeanName, null);
getExternalContext().getRequestMap().remove(managedBeanName);
}
Code:
protected Object getBean(String name) {
return getApplication().getELResolver().getValue(getELContext(), null, name);
}
Code:
protected void setBean(String name, Object value) {
getApplication().getELResolver().setValue(getELContext(), null, name, value);
}
Code:
protected Application getApplication() {
return FacesContext.getCurrentInstance().getApplication();
}
Code:
protected ELContext getELContext() {
return getFacesContext().getELContext();
}
Code:
protected ExternalContext getExternalContext() {
return FacesContext.getCurrentInstance().getExternalContext();
}
Code:
protected FacesContext getFacesContext() {
return FacesContext.getCurrentInstance();
}
Any feedback much appreciated. I have yet to test this with concurrent dom so that should be interesting.