From the course: Learning Java Enterprise Edition
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution - Java EE Tutorial
From the course: Learning Java Enterprise Edition
Solution
- [Instructor] For this solution, you will need a method that listens for cargo events and a collection in which to store the cargo objects. Here is the class RealtimeCargoTrackingService. As you can see, we have an onCargoInspecting method, and in this method, we're observing for events of type cargo. So this should give you a hint as to what we need to do. I've already implemented the solution here. What you can see, we have this onCargoInspect method. It observes for events of type cargo, and it stores each cargo event that it observes into a collection called cargos. Also, you'll notice that the class is annotated @ApplicationScoped and also is annotated @Named. This class will be a backing bean, so that it is visible to a JSF view, and also, it should have @ApplicationScoped because we want it to maintain the list of cargos across sessions. Now we need a view to display the cargos. Here, I have created a view named showHandledCargos, and I use the data table component from…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.