private ReservationTO reservation;
private StringValue readerId;
public EditReservation(final PageParameters parameters) {
super(parameters);
ReaderService readerService = (ReaderService) ApplicationContextProvider.getApplicationContext().getBean("readerService");
BookService bookService = (BookService) ApplicationContextProvider.getApplicationContext().getBean("bookService");
readerId = parameters.get("readerId");
reservation = new ReservationTO();
add(new Label("title", new Model("Create reservation for "
+ readerService.findReaderById(readerId.toLong()).getSurname() + " "
+ readerService.findReaderById(readerId.toLong()).getFirstName())));
Form<?> form = new Form("form") {
@Override
protected void onSubmit() {
ReservationService reservationService = (ReservationService) ApplicationContextProvider.getApplicationContext().getBean("reservationService");
ReaderService readerService = (ReaderService) ApplicationContextProvider.getApplicationContext().getBean("readerService");
java.util.Date date = new java.util.Date();
reservation.setReservationDate(new Timestamp(date.getTime()));
reservation.setReaderTO(readerService.findReaderById(readerId.toLong()));
reservationService.insertReservation(reservation);
setResponsePage(ShowAllReservation.class);
}
};
add(form);