Java Reference
In-Depth Information
@Inject TheatreBox box;
private List<Seat> seats;
@Produces [2]
@Named
public List<Seat>getSeats() {
return seats;
}
public void
onMemberListChanged(@Observes(notifyObserver =
Reception.IF_EXISTS) final Seat member) {
retrieveAllSeatsOrderedByName(); [3]
}
@PostConstruct
public void retrieveAllSeatsOrderedByName() {
seats = box.getSeatList();
}
}
At first, have a look at the @Model annotation [1] , which is an alias for two com-
monly used annotations: @Named and @RequestScoped . Therefore, this bean will
be "named" into our JSF page and will carry a request scope.
Next, pay attention to the method getSeats . This method returns a list of seats, ex-
posing it as a producer method [2] .
Note
Producer methods allow control over the production of the dependency objects.
As a Java Factory pattern, they can be used as a source of objects whose imple-
Search WWH ::




Custom Search