Example usage for org.apache.wicket.extensions.captcha.kittens KittenCaptchaPanel KittenCaptchaPanel

List of usage examples for org.apache.wicket.extensions.captcha.kittens KittenCaptchaPanel KittenCaptchaPanel

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.captcha.kittens KittenCaptchaPanel KittenCaptchaPanel.

Prototype

public KittenCaptchaPanel(final String id, final Dimension imageSize) 

Source Link

Usage

From source file:it.av.eatt.web.page.SignUpPanel.java

License:Apache License

/**
 * Constructor/*from   w  w  w.jav a  2 s . co  m*/
 * 
 * @param id
 * @param feedbackPanel
 * @param userService
 * @throws JackWicketException
 */
public SignUpPanel(String id, FeedbackPanel feedbackPanel, EaterService userService,
        CountryService countryService) throws JackWicketException {
    super(id);
    this.userService = userService;
    this.feedbackPanel = feedbackPanel;

    RfcCompliantEmailAddressValidator emailAddressValidator = RfcCompliantEmailAddressValidator.getInstance();
    StringValidator pwdValidator = StringValidator.LengthBetweenValidator.lengthBetween(6, 20);

    Eater user = new Eater();
    signUpForm = new Form<Eater>("signUpForm", new CompoundPropertyModel<Eater>(user));

    signUpForm.setOutputMarkupId(true);
    signUpForm.add(new RequiredTextField<String>(Eater.FIRSTNAME));
    signUpForm.add(new RequiredTextField<String>(Eater.LASTNAME));
    signUpForm.add(new RequiredTextField<String>(Eater.EMAIL).add(emailAddressValidator));
    List<Country> countriyList = countryService.getAll();
    Country userCountry = null;
    for (Country country : countriyList) {
        if (country.getIso3().equals(getRequest().getLocale().getISO3Country())) {
            userCountry = country;
        }
    }
    DropDownChoice<Country> country = new DropDownChoice<Country>(Eater.COUNTRY, countryService.getAll());
    // country.setDefaultModelObject(userCountry);
    signUpForm.add(country);
    signUpForm.add(new DropDownChoice<Language>("language", languageService.getAll(), new LanguageRenderer())
            .setRequired(true));
    PasswordTextField pwd1 = new PasswordTextField(Eater.PASSWORD);
    pwd1.add(pwdValidator);
    signUpForm.add(pwd1);
    PasswordTextField pwd2 = new PasswordTextField("password-confirm", new Model(passwordConfirm));
    signUpForm.add(pwd2);
    EqualPasswordInputValidator passwordInputValidator = new EqualPasswordInputValidator(pwd1, pwd2);
    signUpForm.add(passwordInputValidator);
    SubmitButton submitButton = new SubmitButton("buttonCreateNewAccount", signUpForm);
    signUpForm.add(submitButton);
    signUpForm.setDefaultButton(submitButton);

    goSignInAfterSignUp = new Link<String>("goSignInAfterSignUp") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            setResponsePage(SignIn.class);
        }
    };
    goSignInAfterSignUp.setOutputMarkupId(true);
    goSignInAfterSignUp.setVisible(false);
    add(goSignInAfterSignUp);

    signUpForm.add(captcha = new KittenCaptchaPanel("captcha", new Dimension(400, 200)));
    add(signUpForm);
}

From source file:it.av.youeat.web.page.PasswordRecoverPage.java

License:Apache License

/**
 * Constructor./*from   w w  w.j  ava  2s  .  co  m*/
 */
public PasswordRecoverPage() {
    add(getFeedbackPanel());
    Form<PasswordRecoverBean> pwdRecoverForm = new Form<PasswordRecoverBean>("pwdRecoverForm",
            new CompoundPropertyModel<PasswordRecoverBean>(new PasswordRecoverBean()));
    final KittenCaptchaPanel captcha = new KittenCaptchaPanel("captcha", new Dimension(400, 200));
    pwdRecoverForm.add(captcha);
    // used to show error message
    final HiddenField<String> captchaHidden = new HiddenField<String>("captchaHidden", new Model());
    pwdRecoverForm.add(captchaHidden);
    pwdRecoverForm.add(new KittenCaptchaValidator(captchaHidden, captcha));
    add(pwdRecoverForm);
    pwdRecoverForm.add(new RequiredTextField<String>("email").add(new EmailCheckExistValidator())
            .add(new EmailCheckExistValidator()));
    add(pwdRecoverForm);
    add(new SubmitButton("buttonRecoverPassword", pwdRecoverForm));

    goSignInAfterRecover = new Link<String>("goSignInAfterRecover") {

        @Override
        public void onClick() {
            setResponsePage(SignIn.class);
        }
    };
    goSignInAfterRecover.setOutputMarkupPlaceholderTag(true);
    goSignInAfterRecover.setVisible(false);
    add(goSignInAfterRecover);
}

From source file:it.av.youeat.web.panel.SignUpPanel.java

License:Apache License

/**
 * Constructor//w ww.j a v  a  2 s. c  o  m
 * 
 * @param id
 * @param feedbackPanel
 * @param eaterService
 * @throws YoueatException
 */
public SignUpPanel(String id, FeedbackPanel feedbackPanel) throws YoueatException {
    super(id);
    Injector.get().inject(this);
    this.feedbackPanel = feedbackPanel;

    List<Country> countryList = countryService.getAll();
    Country userCountry = null;
    for (Country country : countryList) {
        if (country.getIso3().equals(getRequest().getLocale().getISO3Country())) {
            userCountry = country;
        }
    }
    RfcCompliantEmailAddressValidator emailAddressValidator = RfcCompliantEmailAddressValidator.getInstance();
    StringValidator pwdValidator = StringValidator.LengthBetweenValidator.lengthBetween(6, 20);
    EmailPresentValidator emailPresentValidator = new EmailPresentValidator();

    Eater user = new Eater();
    user.setCountry(userCountry);
    user.setLanguage(languageService.getSupportedLanguage(getLocale()));

    signUpForm = new Form<Eater>("signUpForm", new CompoundPropertyModel<Eater>(user));

    signUpForm.setOutputMarkupId(true);
    signUpForm.add(new RequiredTextField<String>(Eater.FIRSTNAME));
    signUpForm.add(new RequiredTextField<String>(Eater.LASTNAME));
    signUpForm.add(
            new RequiredTextField<String>(Eater.EMAIL).add(emailAddressValidator).add(emailPresentValidator));

    DropDownChoice<Country> country = new DropDownChoice<Country>(Eater.COUNTRY, countryService.getAll(),
            new CountryRenderer());
    country.setRequired(true);
    signUpForm.add(country);
    signUpForm.add(new DropDownChoice<Language>("language", languageService.getAll(), new LanguageRenderer())
            .setRequired(true));
    PasswordTextField pwd1 = new PasswordTextField(Eater.PASSWORD);
    pwd1.add(pwdValidator);
    signUpForm.add(pwd1);
    PasswordTextField pwd2 = new PasswordTextField("password-confirm", new Model<String>(passwordConfirm));
    signUpForm.add(pwd2);
    EqualPasswordInputValidator passwordInputValidator = new EqualPasswordInputValidator(pwd1, pwd2);
    signUpForm.add(passwordInputValidator);
    SubmitButton submitButton = new SubmitButton("buttonCreateNewAccount", signUpForm);
    submitButton.setOutputMarkupId(true);
    add(submitButton);
    signUpForm.setDefaultButton(submitButton);
    DropDownChoice<Sex> sexField = new DropDownChoice<Sex>("sex", Arrays.asList(Sex.values()));
    sexField.setRequired(true);
    signUpForm.add(sexField);
    goSignInAfterSignUp = new Link<String>("goSignInAfterSignUp") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            setResponsePage(SignIn.class);
        }
    };
    goSignInAfterSignUp.setOutputMarkupId(true);
    goSignInAfterSignUp.setOutputMarkupPlaceholderTag(true);
    goSignInAfterSignUp.setVisible(false);
    add(goSignInAfterSignUp);
    KittenCaptchaPanel captcha = new KittenCaptchaPanel("captcha", new Dimension(400, 200));
    signUpForm.add(captcha);
    // used to show error message
    final HiddenField<String> captchaHidden = new HiddenField<String>("captchaHidden", new Model());
    signUpForm.add(captchaHidden);
    signUpForm.add(new KittenCaptchaValidator(captchaHidden, captcha));
    add(signUpForm);
}