December 2017
Intermediate to advanced
372 pages
8h 46m
English
To handle CDI events, the CDI bean handling the event needs to implement an observer method. The observer method accepts a parameter of the type that was used to fire the event, that is, the generic type used to create the event that was fired. In our example, the generic type of our event is an instance of a class named NavigationInfo, as can be seen in the declaration of our event in the preceding section. To handle the event, the observer method needs to annotate the corresponding parameter with the @Observes annotation, as illustrated in the following example:
package net.ensode.javaee8book.cdievents.eventlistener; import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.enterprise.event.Observes; ...