7
votes

As far as I know that JSF keeps all the session scoped bean in some kind of Map (correct me if I am wrong.). In my application I have session scoped (managed by Spring and injected into the backing bean) bean named "userDetailsBean".

Is it possible to get all the instances of the bean created for different user in some sort of collection by the help of JSF API?

1

1 Answers

10
votes

Add and remove them to/from some applicationwide collection/mapping yourself during @PostConstruct and @PreDestroy.

@PostConstruct
public void init() {
    allSessionScopedBeans.add(this);
}

@PreDestroy
public void destroy() {
    allSessionScopedBeans.remove(this);
}