2015-06-08 71 views
1

我用钻嘴鱼科2.1.29,有一个会话范围的JSF托管bean重新创建会话范围的JSF托管bean编程

@ManagedBean 
@SessionScoped 
public class UserContext{ 

    //staff 

} 

和一个Spring bean:

public class UserReproducer{ 
    private User user; 

    public void reporoduce(){ 
     if(user == null){ 
      //Here I need to recreate the userContext managed bean 
      //do some other staff 
     } 
    } 
} 

事实上,我需要JSF中的某种自定义作用域,即在条件满足时重新创建userContext bean。有可能以某种方式做到吗?通过重新创建,我的意思是清理所有属性,因为它是第一次创建。

回答

-1

无效会话,摧毁一个会话范围的bean:

FacesContext.getCurrentInstance().getExternalContext().invalidateSession(); 

从春季安全注销另一种选择是疏通脉络:

SecurityContextHolder.clearContext(); 
+0

我怎样才能做到这一点? – user3663882

+0

会议是否与春季安全会议相关?我的意思是说同样的事情? – user3663882

+0

SecurityContext对象保存在http会话中是。 – Stefan