We have faces-config.xml in JSF 1.0 where we entry about managed-beans, dependencies & navigations etc.
I was developing a sample project using JSF 2.0. But, as I don’t know annotation, I need to include face-config.xml externally. Please, provide the solution for it, as in JSF 2.0 we don’t need to include it. What is reason behind it? How do we set a bean as managed-bean. What is annotation? How is it used?
In three words: ease of development. There is just less code to write — boilerplate code is removed, defaults are used whenever possible, and annotations are used to reduce the need for deployment descriptors.
Managed beans are identified using the
@ManagedBeanannotation. The scope of the bean is also specified using annotations (@RequestScoped,@SessionScoped,@ApplicationScoped, etc).So the following in JSF 1.0:
Can be rewritten as such in JSF 2.0:
And referred like this in a Facelet page:
(By default, the name of the managed bean will be the name of the annotated class, with the first letter of the class in lowercase.)
See also