Managed bean communication

Until now, we have focused especially on the communication between Facelets and managed beans. In this section, we will cover another important aspect regarding JSF communication—managed beans communication. We will discuss the following topics:

  • Injecting a managed bean into another bean
  • Communication between managed beans using the application/session map
  • Accessing other managed beans programmatically

Injecting a managed bean into another bean

A managed bean can be injected into another managed bean using @ManagedProperty. For example, let's suppose that you have a managed bean in the session scope that stores a player name and surname, as shown in the following code:

@Named @SessionScoped public class PlayersBean implements ...

Get Mastering JavaServer Faces 2.2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.