Thursday, March 19, 2009

How-to get or remove a jsf backing bean from session?

To reset session bean

FacesContext
.getCurrentInstance()
.getApplication()
.createValueBinding( "#{yourBeanName}").setValue(FacesContext.getCurrentInstance(), null );



To get session bean reference

Object obj = FacesContext
.getCurrentInstance()
.getApplication()
.createValueBinding("#{yourBeanName}")
.getValue(FacesContext.getCurrentInstance());
 
YourSessionBean bean = (YourSessionBean)obj;

1 comment:

  1. We can also get managed bean from session map

    Object obj = FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("name of your managed bean")

    ReplyDelete