1
votes

I'm using Mojarra 2.1.29 and have a session scoped JSF managed bean

@ManagedBean
@SessionScoped
public class UserContext{

   //staff

}

and a 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
        }
    }
}

In fact, I need some kind of custom scope in JSF, i.e. to re-create the userContext bean from scratch when the condition is satisfied. Is it possible to do in some way? By recreating, I mean cleaning all its properties down as it was created for the first time.

1

1 Answers

-1
votes

Invalidate the session, to destroy a session scoped bean:

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

Another option to log out from Spring Security is to clear the context:

SecurityContextHolder.clearContext();