Package de.agilecoders.wicket.core.markup.html.bootstrap.common

Examples of de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationMessage


//        //assertInfoMessages cannot be used with NotificationMessage messages - a quick hack can be made more generic
//        tester.assertInfoMessages("You have successfully registered for access to this application.");
        List<Serializable> actualMessages = tester.getMessages(FeedbackMessage.INFO);
        assertEquals(1, actualMessages.size());
        assertEquals(NotificationMessage.class, actualMessages.get(0).getClass());
        NotificationMessage actualMessage = (NotificationMessage) actualMessages.get(0);
        assertEquals(expectedMessage, actualMessage.message().getObject());
    }
View Full Code Here


        String username = parameters.get("username").toString();
        log.debug("username {}", username);

        if (username == null || "".equals(username)) {
            log.warn("Username not specified, notifying user that it's a required field.");
            getSession().error(new NotificationMessage(
                    new StringResourceModel("errors.required", this, null, new Object[]{"username"})));
            throw new RestartResponseException(Login.class);
        }

        log.debug("Processing Password Hint for username: {}", username);

        // look up the user's information
        try {
            User user = userManager.getUserByUsername(username);

            StringBuilder msg = new StringBuilder();
            msg.append("Your password hint is: ").append(user.getPasswordHint());
            msg.append("\n\nLogin at: ")
                    .append(RequestCycle.get().getUrlRenderer().renderFullUrl(
                            Url.parse(urlFor(Login.class, null).toString())));

            SimpleMailMessage message = new SimpleMailMessage();
            message.setTo(user.getEmail());

            String subject = '[' + getString("webapp.name") + "] " + getString("user.passwordHint");
            message.setSubject(subject);
            message.setText(msg.toString());
            log.debug("subject: {}", subject);
            log.debug("message: {}", message);
            mailEngine.send(message);

            getSession().info(createDefaultInfoNotificationMessage(new StringResourceModel(
                    "login.passwordHint.sent", this, null, new Object[] {username, "provided email address"})));
        } catch (UsernameNotFoundException e) {
            log.warn(e.getMessage());
            // This exception is expected to not be rethrown
            getSession().error(new NotificationMessage(new StringResourceModel(
                    "login.passwordHint.error", this, null, new Object[] {username})));
        } catch (MailException me) {
            log.error(me.getMessage(), me);
            getSession().error(new NotificationMessage(new ResourceModel("errors.sending.email")));
        }

        throw new RestartResponseException(Login.class);
    }
View Full Code Here

            getSession().info(createDefaultInfoNotificationMessage(
                    new StringResourceModel("user.added", this, null, new Object[]{user.getFullName()})));
            resolveAndSetResponsePage();
        } catch (UserExistsException e) {
            log.warn("User already exists", e);
            error(new NotificationMessage(new StringResourceModel("errors.existing.user", this, null, new Object[] {
                    user.getUsername(), user.getEmail()})));
        }
    }
View Full Code Here

            getSession().setLocale(getRequest().getLocale());
        }
    }

    protected NotificationMessage createDefaultInfoNotificationMessage(IModel<String> messageModel) {
        return new NotificationMessage(messageModel)
                .hideAfter(Duration.seconds(5));
    }
View Full Code Here

            getSession().info(createDefaultInfoNotificationMessage(
                    new StringResourceModel("user.added", this, null, new Object[]{user.getFullName()})));
            resolveAndSetResponsePage();
        } catch (UserExistsException e) {
            log.warn("User already exists", e);
            error(new NotificationMessage(new StringResourceModel("errors.existing.user", this, null, new Object[] {
                    user.getUsername(), user.getEmail()})
            ));
        }
    }
View Full Code Here

    private void sendMessage(SimpleMailMessage message) {
        try {
            mailEngine.send(message);
        } catch (MailException me) {
            log.error(me.getMostSpecificCause().getMessage(), me);
            getSession().warn(new NotificationMessage(new ResourceModel("errors.sending.email")));
        }
    }
View Full Code Here

        // issue #102
        add(new BootstrapLink<Page>("link", Model.<Page>of(this)) {
            @Override
            public void onClick() {
                getSession().success(new NotificationMessage(Model.of("link 1 clicked"), Model.of("issue #102:"), true));
                setResponsePage(getModelObject());
            }
        }.setLabel(Model.of("Link 1")));
        add(new BootstrapLink<Page>("link-danger", Model.<Page>of(this), Buttons.Type.Danger) {
            @Override
            public void onClick() {
                getSession().success(new NotificationMessage(Model.of("link 2 <u>clicked</u>"), Model.of("issue #102:"), true).escapeModelStrings(false));
                setResponsePage(getModelObject());
            }
        }.setLabel(Model.of("Link 2")));

        add(createColorPickerForm("colorpicker-form"));
View Full Code Here

TOP

Related Classes of de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationMessage

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.