Package org.jboss.seam.examples.booking.i18n

Examples of org.jboss.seam.examples.booking.i18n.DefaultBundleKey


            /*
             * FIXME: This is an ugly way to put i18n in FacesMessages: https://jira.jboss.org/browse/SEAMFACES-24
             */

            throw new ValidatorException(new FacesMessage(messageBuilder
                    .key(new DefaultBundleKey("account_passwordsDoNotMatch")).defaults("Passwords do not match").build()
                    .getText()));
        }
    }
View Full Code Here


            return;
        }

        if (!password.equals(confirmPassword)) {
            throw new ValidatorException(new FacesMessage(messageBuilder
                    .key(new DefaultBundleKey("account_passwordsDoNotMatch")).defaults("Passwords do not match").build()
                    .getText()));
        }
    }
View Full Code Here

    public void register() {
        if (verifyUsernameIsAvailable()) {
            registered = true;
            em.persist(newUser);

            messages.info(new DefaultBundleKey("registration_registered"))
                    .defaults("You have been successfully registered as the user {0}! You can now login.")
                    .params(newUser.getUsername());
        } else {
            registrationInvalid = true;
        }
View Full Code Here

     * <f:event type="preRenderView" listener="#{registrar.notifyIfRegistrationIsInvalid}"/>
     * </pre>
     */
    public void notifyIfRegistrationIsInvalid() {
        if (facesContext.isValidationFailed() || registrationInvalid) {
            messages.warn(new DefaultBundleKey("registration_invalid")).defaults(
                    "Invalid registration. Please correct the errors and try again.");
        }
    }
View Full Code Here

    private boolean changed;

    public void changePassword() {
        em.merge(user);
        messages.info(new DefaultBundleKey("account_passwordChanged")).defaults("Password successfully updated.");
        changed = true;
    }
View Full Code Here

        // for demo convenience
        booking.setCreditCardNumber("1111222233334444");
        log.bookingInitiated(user.getName(), booking.getHotel().getName());

        messages.info(new DefaultBundleKey("booking_initiated")).defaults("You've initiated a booking at the {0}.")
                .params(booking.getHotel().getName());
    }
View Full Code Here

        hotelSelection = null;
    }

    public void onBookingComplete(@Observes(during = TransactionPhase.AFTER_SUCCESS) @Confirmed final Booking booking) {
        log.bookingConfirmed(booking.getHotel().getName(), booking.getUser().getName());
        messages.info(new DefaultBundleKey("booking_confirmed")).defaults("You're booked to stay at the {0} {1}.")
                .params(booking.getHotel().getName(), new PrettyTime(locale).format(booking.getCheckinDate()));
    }
View Full Code Here

        Date endDate = endDateElement.getValue();

        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_MONTH, -1);
        if (startDate.before(calendar.getTime())) {
            String message = messageBuilder.get().key(new DefaultBundleKey("booking_checkInNotFutureDate"))
                    .targets(startDateElement.getClientId()).build().getText();
            throw new ValidatorException(new FacesMessage(message));
        } else if (!startDate.before(endDate)) {
            String message = messageBuilder.get().key(new DefaultBundleKey("booking_checkOutBeforeCheckIn"))
                    .targets(endDateElement.getClientId()).build().getText();
            throw new ValidatorException(new FacesMessage(message));
        }
    }
View Full Code Here

    public void cancelBooking(final Booking selectedBooking) {
        log.infov("Canceling booking {0} for {1}", selectedBooking.getId(), currentUserInstance.get().getName());
        Booking booking = entityManager.find(Booking.class, selectedBooking.getId());
        if (booking != null) {
            entityManager.remove(booking);
            messages.info(new DefaultBundleKey("booking_canceled"))
                    .defaults("The booking at the {0} on {1} has been canceled.")
                    .params(selectedBooking.getHotel().getName(),
                            DateFormat.getDateInstance(SimpleDateFormat.MEDIUM).format(selectedBooking.getCheckinDate()));
        } else {
            messages.info(new DefaultBundleKey("booking_doesNotExist")).defaults(
                    "Our records indicate that the booking you selected has already been canceled.");
        }

        bookingsForUser.remove(selectedBooking);
    }
View Full Code Here

    private Event<User> loginEventSrc;

    public void authenticate() {
        log.info("Logging in " + credentials.getUsername());
        if ((credentials.getUsername() == null) || (credentials.getCredential() == null)) {
            messages.error(new DefaultBundleKey("identity_loginFailed")).defaults("Invalid username or password");
            setStatus(AuthenticationStatus.FAILURE);
        }
        User user = em.find(User.class, credentials.getUsername());
        if (user != null && credentials.getCredential() instanceof PasswordCredential &&
            user.getPassword().equals(((PasswordCredential) credentials.getCredential()).getValue())) {
            loginEventSrc.fire(user);
            messages.info(new DefaultBundleKey("identity_loggedIn"), user.getName()).defaults("You're signed in as {0}")
                    .params(user.getName());
            setStatus(AuthenticationStatus.SUCCESS);
            setUser(new SimpleUser(user.getUsername())); //TODO confirm the need for this set method
            return;
        }

        messages.error(new DefaultBundleKey("identity_loginFailed")).defaults("Invalid username or password");
        setStatus(AuthenticationStatus.FAILURE);

    }
View Full Code Here

TOP

Related Classes of org.jboss.seam.examples.booking.i18n.DefaultBundleKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.