public ShowAllReservation(final PageParameters parameters) {
super(parameters);
RepeatingView repeating = new RepeatingView("repeating");
add(repeating);
ReservationService reservationService = (ReservationService) ApplicationContextProvider.getApplicationContext().getBean("reservationService");
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
for (ReservationTO reservation : reservationService.findAllReservations()) {
AbstractItem item = new AbstractItem(repeating.newChildId());
PageParameters pageParameters = new PageParameters();
item.add(new BookmarkablePageLink<Void>("delete", ShowAllReservation.class, pageParameters));
pageParameters.add("reservationid", reservation.getReservationID());
item.add(new Label("readerTO", reservation.getReaderTO().toString()));
item.add(new Label("bookTO", reservation.getBookTO().toString()));
item.add(new Label("reservationDate", dateFormat.format(reservation.getReservationDate())));
repeating.add(item);
}
//delete reservation
StringValue reservationId = parameters.get("reservationid");
if (!reservationId.isEmpty()) {
reservationService.deleteReservation(reservationService.findReservationByID(reservationId.toLong()));
setResponsePage(ShowAllReservation.class);
}
BookmarkablePageLink createLink = new BookmarkablePageLink<>(
"create", ShowAllReader.class);