Skip to Main Content
Mastering JavaServer Faces 2.2
book

Mastering JavaServer Faces 2.2

by Anghel Leonard
June 2014
Intermediate to advanced content levelIntermediate to advanced
578 pages
12h 2m
English
Packt Publishing
Content preview from Mastering JavaServer Faces 2.2

Configuring managed beans in XML

JSF managed bean configuration was essentially improved starting with JSF 2.0. Most commonly, a managed bean is annotated with @ManagedBean and another annotation indicating a JSF scope (for example, @RequestScoped). But managed beans can be configured in faces-config.xml as well, and this approach is not deprecated or obsolete. The simplest configuration contains the managed bean's name, class, and scope:

<managed-bean>
  <managed-bean-name>playersBean</managed-bean-name>
  <managed-bean-class>book.beans.PlayersBean</managed-bean-class>
  <managed-bean-scope>request</managed-bean-scope>
...
</managed-bean>

Note

In case that you need a managed bean that should be eagerly initialized, you can use the eager attribute of the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaServer Faces

JavaServer Faces

Hans Bergsten

Publisher Resources

ISBN: 9781782176466Supplemental Content