Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all the session scoped beans in JSF 2?

Tags:

spring

jsf-2

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?

like image 614
user1220373 Avatar asked Jun 26 '12 16:06

user1220373


1 Answers

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);
}
like image 167
BalusC Avatar answered Sep 21 '22 23:09

BalusC