Java Reference
In-Depth Information
public void onListChanged(@Observes(notifyObserver =
Reception.IF_EXISTS) final SeatType member) {
retrieveAllSeatTypes();
}
}
If you have gone through our example in Chapter 4 , Learning Context and Dependency
Injection , you will find nothing new here; as you can see, the class will merely produce a
collection of seatTypes , which is tagged as @Named so that they can be accessed from
JSF EL as well. Additionally, the class contains an observer handler method
( onListChanged ), which will be fired when data in the collection is changed.
The collection data is filled using the retrieveAllSeatTypes method (loaded the
first and only time when the class is constructed) of the SeatTypeDao CDI Bean. We
will define this bean in a moment; right now, we will add the last producer class used in
this example, the SeatProducer bean:
@javax.enterprise.context.RequestScoped
public class SeatProducer implements Serializable {
@Inject
private SeatDao seatDao;
private List<Seat> seats;
@PostConstruct
public void retrieveAllSeats() {
seats = seatDao.findAllSeats();
}
@Produces
@Named
public List<Seat> getSeats() {
return seats;
}
public void
onMemberListChanged(@Observes(notifyObserver =
Reception.IF_EXISTS) final Seat member) {
Search WWH ::




Custom Search