0
votes

I have already asked about @ViewScoped managed beans here:

Commandlink action and @viewscoped weird behaviour

Unfortunately in the books and documentation about JSF I have there are only hints to the @ViewScoped annotation and its behind the scenes mechanisms are not unveiled. So, after some terrible headaches with my JSF beans, I did some test on Mojarra 2.1 and I got some new weird (to me) results.

First of all doing successive Get requests to the same page the linked @ViewScoped managed bean is re-created every time. I would have expected the same behavior of successive Post to the same page, that is the managed bean survives between the posts and it is not created again.

When a new @Viewscoped managed bean is created that doesn't imply the previous one is destroyed. Surprisingly (for me) it remains accessible for some time. I noticed this fact using the browser back button (I know it is a no no ): I could retrieve some detail data from a managed bean which was supposed to be 'expired' because a new one, with different filter data, was created.

Can you confirm my results are correct ? Where can I find infos on the @ViewScoped internal mechanisms without having to look at its code ?

Thanks Filippo

1

1 Answers

1
votes

I recommend to take a look at BalusC's excellent article "Communication in JSF 2.0" with a chapter on the topic why ViewScoped beans sometimes behave like RequestScoped ones (@ViewScoped fails in tag handlers).