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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top