@SessionScoped
@ManagedBean
from a JSF application. We both thought about using the code below, and in fact it works, but it left me feeling that this was too specific.1 2 3 | public void removeSessionBean( final String beanName) { FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove(beanName); } |
I thought a better approach would be to just "find" the bean and set it to
null
. Using an ELResolver
I thought would be better since I could just look for a bean in a more general way.
1 2 3 4 | public void removeManagedBean( final String beanName) { FacesContext fc = FacesContext.getCurrentInstance(); fc.getELContext().getELResolver().setValue(fc.getELContext(), null , beanName, null ); } |
0 comments :
Post a Comment