The problem: You are programming a web application which has to support more than one window. Data has to be shown in different tabs of the browser in parallel, so you use the @ViewScoped annotation in your CDI controller. Now you are able to use different tabs at the same time, but when the user clicks the reload button their view specific data will be lost.
The solution is to use the @ViewAccessScoped annotation. It gives your rendered view a unique id by which it can be identified. To use it you either need to include the JAR or just use the Maven dependency, like shown below. Just put this into your pom.xml and you should be able to use the @ViewAccessScoped annotation.
Maven dependency, which contains the @ViewAccessScoped annotation:
<dependency> <groupId>org.apache.myfaces.extensions.cdi.core</groupId> <artifactId>myfaces-extcdi-core-api</artifactId> <version>1.0.6</version> </dependency>
Note: This is a myfaces extension, but it works also with mojarra.