You'd need a new @RequestScoped bean that creates your existing bean class via the normal new operator (i.e. not injected). You can't simultaneously treat a single bean obtained by the container as request and session scoped.
CDI - Sessions Scope - New session scope for each request scope
-
14-06-2023 - |
Question
I have a @SessionScoped CDI bean which is nicely storing information per user session. However I would like to use the same bean but have a new instance of it in say a request scope but once it gets created it remains in the session for that request. So for another request I want it to create a new bean.
Is this possible using CDI?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow