Example usage for org.apache.wicket.markup.html.form RequiredTextField RequiredTextField

List of usage examples for org.apache.wicket.markup.html.form RequiredTextField RequiredTextField

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.form RequiredTextField RequiredTextField.

Prototype

public RequiredTextField(final String id, IModel<T> model, Class<T> type) 

Source Link

Usage

From source file:de.inren.frontend.auth.LoginPanel.java

License:Apache License

@Override
protected void onInitialize() {
    super.onInitialize();
    final Form<Void> signInForm = new Form<Void>("form") {

        @Override//from   www . j  a  va  2s .c  om
        protected void onInitialize() {
            super.onInitialize();
            final StringResourceModel lEmail = new StringResourceModel("email.label", LoginPanel.this, null);
            add(new Label("email.label", lEmail));
            email = new RequiredTextField<String>("email", new PropertyModel<String>(properties, "email"),
                    String.class);
            add(email.setLabel(lEmail));

            final StringResourceModel lPass = new StringResourceModel("password.label", LoginPanel.this, null);
            add(new Label("password.label", lPass));
            password = new PasswordTextField("password", new PropertyModel<String>(properties, "password"));
            add(password.setType(String.class).setLabel(lPass));

            BootstrapButton signInButton = new BootstrapButton("signup", new ResourceModel("signup.label"),
                    Buttons.Type.Link) {
                @Override
                public void onSubmit() {
                    // TODO redirect to subscribe page
                    error("Signup not implemented yet.");
                    invalid();
                }
            };
            signInButton.setDefaultFormProcessing(false);
            add(signInButton);
            add(new BootstrapButton("submit", new ResourceModel("submit.label"), Buttons.Type.Primary) {
                @Override
                public void onSubmit() {
                    super.onSubmit();
                    if (getBasicAuthenticationSession().signIn(getEmail(), getPassword())) {
                        ApplicationSettingsUtil.applySettings(getUserSettings());

                        continueToOriginalDestination();
                        setResponsePage(getApplication().getHomePage());
                    } else {
                        error(new StringResourceModel("signInFailed", LoginPanel.this, null).getString());
                    }
                }

            });
        }
    };
    add(signInForm);
}