0
votes

First:

I have two Managed Beans.

Bean A:

  • @ViewScope
  • Contains a lazyloading datatable depending on some session value, initialized in the @PostConstruct

Bean B:

  • @ViewScope
  • Changing the session value which is used in Bean A

I do following;

  • setting my session data with the JSF site using Bean B
  • loading the jsf site which uses Bean A
  • setting other session data with Bean B
  • loading the jsf which uses Bean A again

The Problem is following:

If I am loading the JSF site with Bean A again, the PostConstruct which is initializing the datatable is not loaded again.

I thought that if I use the view scope, the ManagedBean would be destroyed if I navigate through different JSF sites.

Please help me to understand this Problem. What am I doing wrong?

1
How exactly are you performing the step "loading the jsf which uses Bean A again". By a new HTTP GET request, right?BalusC
And that request is for sure not served from the browser cache? Okay, how are you managing your beans? Using JSF's own @javax.faces.bean.ManagedBean or something else?BalusC
Every bean is annotated with javax.faces.bean.ManagedBean and there own view annotation javax.faces.bean.ViewScoped for this case. For the most beans I use javax.faces.bean.RequestScoped but in this case I need to reload the constructor or the post construct because I have a depend on an other object the user can select in other jsf sites.Nils
The JSF Site which is using Bean A has a Dialog, which uses an other managed Bean C, also with ViewScoped. Is that a maybe a Problem?Nils
Normaly I use a jetty. Deploying my application in tomcat does following: I started some get requests on the SAME jsf site using Bean A and C and every time both managed beans with ViewScoped linked, get created new..Nils

1 Answers

0
votes

It should yes. The view scope should stay in-tact for as long as you stay on the same view.

There have been many problems with this scope in past versions of JSF however, including relating to PostConstruct; which version are you using right now? It should mention that in the logs during application startup.