Java Reference
In-Depth Information
Next in the list is the bookSeat method, which, as you might have guessed, will be used
to book a seat. Finally, the doCleanUp method is actually used to perform a cleanup if
you want to restart the application.
The last piece of our puzzle is the BookerService class, which adds a tiny session lay-
er to your application:
@Named
@javax.faces.view.ViewScoped
public class BookerService implements Serializable {
private static final long serialVersionUID =
-4121692677L;
@Inject
private Logger logger;
@Inject
private TicketService ticketService;
@Inject
private FacesContext facesContext;
private int money;
@PostConstruct
public void createCustomer() {
this.money = 100;
}
public void bookSeat(long seatId, int price) {
logger.info("Booking seat " + seatId);
if (price > money) {
final FacesMessage m = new
FacesMessage(FacesMessage.SEVERITY_ERROR, "Not enough
Money!",
"Registration successful");
facesContext.addMessage(null, m);
Search WWH ::




Custom Search