From the course: Learning Java Enterprise Edition

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Solution

Solution - Java EE Tutorial

From the course: Learning Java Enterprise Edition

Start my 1-month free trial

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…

Contents