问题
I created a JSF 2.0 project in Netbeans 6.9. I am starting using CDI. After creating project when i tried to add scope, then i noticed that there is no viewscope in it. I want to know that are the conversation scope and view scope refer to same things? Can i use conversation scope in place of view scope. If no then how can i use view scope with CDI. I also came to know that seam is the solution, but how can i use seam with netbeans. Is there any netbeans plugin for seam? seam-3
Thanks
回答1:
There is no view scope for CDI. The conversation scope is not the same. A view scoped bean lives as long as you work with the same view and survives partial or full reloads of the page.
If you want to use CDI's conversation scope, your application has to set the beginning and end of the conversation.
From my experience you can use CDI scopes together with JSF's view scope (e.g. use CDI scopes for session and application beans and JSF view scope where you need it).
UPDATE: However, you can't inject a managad bean into a CDI bean. The other way around works. And that is the more common case (injecting from a broader scope into the narrower).
回答2:
simply just put seam3 faces module in your classpath or use @ViewAccessScpoed
annotation of myfaces CODI.
来源:https://stackoverflow.com/questions/9580698/how-to-use-view-scope-in-case-of-cdi-in-jsf-2-0