use of org.apache.tapestry5.annotations.OnEvent in project tapestry5-hotel-booking by ccordenier.
the class Book method validateBooking.
@OnEvent(value = EventConstants.VALIDATE, component = "bookingForm")
public void validateBooking() {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH, -1);
if (booking.getCheckinDate().before(calendar.getTime())) {
bookingForm.recordError(messages.get("booking_checkInNotFutureDate"));
return;
} else if (!booking.getCheckinDate().before(booking.getCheckoutDate())) {
bookingForm.recordError(messages.get("booking_checkOutBeforeCheckIn"));
return;
}
userWorkspace.getCurrent().setStatus(true);
}
use of org.apache.tapestry5.annotations.OnEvent in project tapestry5-hotel-booking by ccordenier.
the class View method startBooking.
/**
* Start booking process.
*
* @param hotel
* @return link to the current hotel booking
*/
@OnEvent(value = EventConstants.SUCCESS, component = "startBookingForm")
Object startBooking(Hotel hotel) {
User user = (User) dao.find(User.class, authenticator.getLoggedUser().getId());
userWorkspace.startBooking(hotel, user);
return Book.class;
}
use of org.apache.tapestry5.annotations.OnEvent in project tapestry5-hotel-booking by ccordenier.
the class Signup method proceedSignup.
@OnEvent(value = EventConstants.SUCCESS, component = "RegisterForm")
public Object proceedSignup() {
User userVerif = crudServiceDAO.findUniqueWithNamedQuery(User.BY_USERNAME_OR_EMAIL, QueryParameters.with("username", username).and("email", email).parameters());
if (userVerif != null) {
registerForm.recordError(messages.get("error.userexists"));
return null;
}
User user = new User(fullName, username, email, password);
crudServiceDAO.create(user);
try {
authenticator.login(username, password);
} catch (AuthenticationException ex) {
registerForm.recordError("Authentication process has failed");
return this;
}
return Search.class;
}
Aggregations