Book Image

Mastering JavaServer Faces 2.2

By : Anghel Leonard
Book Image

Mastering JavaServer Faces 2.2

By: Anghel Leonard

Overview of this book

Table of Contents (20 chapters)
Mastering JavaServer Faces 2.2
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
The JSF Life Cycle
Index

JSF scopes versus CDI scopes


Even a JSF beginner might have heard about JSF managed beans (regular JavaBeans classes managed by JSF) and CDI beans (regular JavaBeans classes managed by CDI), and knows that JSF supports JSF scopes and CDI scopes. Starting with Java EE 6, CDI is recognized as the managed bean framework, besides EJBs. This causes confusion among programmers, because EJBs, CDIs, and JSF managed beans raise a critical question: which one to use and when?

Focusing on JSF, the unanimous answer is that CDI beans are more powerful than JSF beans. But, when you know right from the start that CDI will not be a part of your application or you are running the application inside a servlet container (which does not have CDI support by default, like Apache Tomcat), then JSF beans is the right choice. In other words, when you need a simple way to define beans and a neat mechanism for a dependency injection, then JSF bean will do the job, but when you need heavy artillery, such as events,...