My environment: Java 7/JSF 2.1/PrimeFaces 6.1.
My goal: to have a certain page of my application instantiated many times, one for each browser tab, each one with a different context.
My problem: everytime I open a second browser tab requesting from the same url, but with different object id, the previous one is destroyed, so only one backing bean instance is kept alive.
How do I know that: In my backing bean I have one method annotated with @PosConstruct and other with @PreDestroy, so I can track the life cicle of the instances.
My backing bean is annotated as follows:
@ViewController public class MyBackingBeanMB extends AbstractBackingBeanMB { private static final long serialVersionUID = 1L; // many fields and methods } The @ViewController annotation is provided by the application framework I have to use. Such an annotation is declared as:
@Named @Controller @Stereotype @ViewScoped // For me, this should do the trick, but... @Target(value={TYPE}) @Retention(value=RUNTIME) @Inherited public @interface ViewController { } Update 1:
The @Controller annotation is also provided by the framework I use and is declared as:
@InterceptorBinding @Inherited @Target({ TYPE, METHOD }) @Retention(RUNTIME) public @interface Controller { } Any ideas of what could be wrong?
TIA.
@Controllerannotation being one from JSF. And@Viewscopedis not for usage per tab. It is for scope per viewId, effectively resulting in the behaviour you see. You need a@WindowScopedfrom DeltaSpike or use a@ConversationScoped. There is a duplicate about this in Stackoverflow.@Controller. Just did it. Sorry, but we have a bad history with@ConversationScoped, so it is not an option for us, since the medicine was much worse than the decease. Any other ideas?@ViewScope. Is that so?@Controlleris in a custom framework, it is impossible to help further (at least for me since lots of things might happen in there)