I have managed bean by name studentManagedBean. In that bean I have used post construct to intialize studentsList. In another managed bean testbean I was using FacesContext.getCurrentInstance().getExternalContext().invalidateSession(); and redirecting to page students.xhtml where I used to display students.
My question is when I used the FacesContext.getCurrentInstance().getExternalContext().invalidateSession(); and redirected to student.xtml page, init method(post construct) used to call two times. When I commented the above line, init method(post construct) now calls only one time.
can any one tell me what is this invalidate session will exactly do.
@ManagedBean(name = "studentManagedBean" )
@SessionScoped
public class StudentManagedBean implements Serializable {
private List<SBean> stud;
@PostConstruct
private void init(){
this.stud=dao.getAllStudInfo();
}
@ManagedBean(name = "testBean" )
@SessionScoped
public class TestBean implements Serializable {
public String navigate(String name){
if(name.equals("Add student")){
FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
return "student";
}