With the output of Viewscoped from the new JSF specification, what scope do I use now in my managed Beans that used it using JSF 2.2?

Asked

Viewed 4,872 times

12

I have a big question now with the appearance of JSF 2.2: What to do with my views and my old Beans Managed? How to do it now (what scope to use) since I can no longer use view scoped in a view that needs to keep some objects in memory between ajax requests?

  • Why the tags [ejb] and [ejb3]? This question has nothing to do with EJB.

  • Changed tags.

2 answers

8


In accordance with : http://jdevelopment.nl/jsf-22/#1087

La says that the @Viewscoped annotation in the javax.faces.bean.Viewscoped package should become deprecated, given the creation of the @Viewscoped annotation of the javax.faces.view.Viewscoped package.

This happens, after the adoption of a CDI extension, using the second annotation. If you do not use CDI, this annotation will not have any result.

  • Thanks for the clarification, I was confusing and thinking that the class javax.faces.bean.Viewscoped was the one that was going to stay...

  • And in the case of @Sessionscoped, which tag continue using?

3

You can and should use CDI Viewscoped: javax.faces.view.Viewscoped, but of course it is necessary to use CDI Beans.

What happens is that the JSF Viewscoped does not work with Beans CDI, and JSF is taking the course that the CDI Beans will replace the JSF Managed Beans. So they are taking steps to ensure that in the future the whole javax.faces.bean package becomes deprecated.

More information here at this link: http://jdevelopment.nl/jsf-22/#1087

  • This means that for example, a normal web application running in a container Servlet like Tomcat would support the dependency injection context?

  • You don’t need an application server to use CDI, it can be a webcontainer like Tomcat itself.

  • Well @Fred, I’ve been doing a deeper research and I understand a container Servlet to provide the CDI resources need to use a CDI implementation, such as WELD, and this implementation will only cover Servlets 3.0 and not JSF...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.