I have a JSF application that makes much use of session-scoped variables. A new requirement is that the user should be able to open N numbers of the application. However, since much of the state is session-scoped, when the client opens a 2nd instance of the app, view data from the first app bleeds into the newly opened app.
At this point, changing all the session-scoped beans to request-scoped beans would be very difficult. Is there a way to solve this problem at a higher level, by perhaps mapping external (client) sessions with one or more internal (artificially created and used by JSF) session objects?
You can control how the session is provided to the JSF application via the FacesContextFactory (which provides the FacesContext which contains the ExternalContext). This needs to be configured in a faces-config.xml so JSF can pick it up during initialization. If you use a constructor of the form MyFacesConfigFactory(FacesConfigFactory) JSF will pass the previously configured factory, allowing you to decorate the underlying implementation.
Some issues you may encounter:
This is an interesting approach to the problem, but I wouldn’t expect it to be a quick fix.