I have a JSF @ApplicationScoped
bean, MyBean
.
This bean of course is instantiated when I start my JSF application.
I have a RefreshListsTask implements Runnable
which takes a reference to this bean using the JSF ManagedProperty
annotation.
@ManagedProperty(value="#{myBean}")
private MyBean myBean;
This task queries the database every N minutes refreshing a List
inside myBean
To my surprise I've found out I can't get a refreshed list when, from another bean, I invoke:
((MyBean)Faces.evaluateExpressionGet("#{myBean}")).getList();
So I created a new property on this bean, and now it works:
@ManagedProperty(value="#{myBean}")
private MyBean myBean;
...
myBean.getList();
#{myBean}
is being replaced with a new instance at some point (and I get the fresh list obtained when this bean is created, which is never updated again by the RefreshListsTask
, which keeps updating the list on the original bean).
I don't know if this is an issue related to JSF or Omnifaces or if I am doing somethig wrong on my application. I'm almost certain it is the latter, but I can't figure out where is this replacement happening. Any ideas on how to trace this?