Search in sources :

Example 6 with PasswordField

use of com.vaadin.flow.component.textfield.PasswordField in project Test-Bench-Data by DanielMartensson.

the class UserSettingsView method init.

@PostConstruct
public void init() {
    // Create a text field, password field and a button
    Select<String> selectedUser = new Select<String>(masterName, slaveName);
    selectedUser.setLabel("Select user");
    PasswordField newPassword = new PasswordField("New password");
    Button save = new Button("Save new password");
    // Add a listener to the button
    save.addClickListener(e -> {
        // Check if it's selected
        if (selectedUser.isEmpty())
            return;
        // See if you have right to change the password
        if (userPasswordService.loggedInUserIsMaster()) {
            userPasswordService.changePassword(selectedUser.getValue(), newPassword.getValue());
            Notification.show("Success!", 3000, Position.BOTTOM_START);
        } else {
            Notification.show("You don't have master rights to change password!", 3000, Position.BOTTOM_START);
        }
    });
    add(selectedUser, newPassword, save);
}
Also used : Button(com.vaadin.flow.component.button.Button) Select(com.vaadin.flow.component.select.Select) PasswordField(com.vaadin.flow.component.textfield.PasswordField) PostConstruct(javax.annotation.PostConstruct)

Example 7 with PasswordField

use of com.vaadin.flow.component.textfield.PasswordField in project SODevelopment by syampillai.

the class SetMailSenderPassword method createPasswordField.

private PasswordField createPasswordField(String caption) {
    PasswordField f = new PasswordField(caption);
    f.setMaxLength(30);
    return f;
}
Also used : PasswordField(com.vaadin.flow.component.textfield.PasswordField)

Example 8 with PasswordField

use of com.vaadin.flow.component.textfield.PasswordField in project projecte-dam-v2-equip2 by IESEBRE.

the class RegisterView method initContent.

@Override
protected Component initContent() {
    TextField username = new TextField("Nom");
    EmailField email = new EmailField("Email");
    PasswordField password1 = new PasswordField("Contrasenya");
    PasswordField password2 = new PasswordField("Confirmar Contrasenya");
    VerticalLayout register = new VerticalLayout(new H1("Crear usuari"), username, email, password1, password2, new Button("Crear", event -> register(username.getValue(), email.getValue(), password1.getValue(), password2.getValue())));
    register.setAlignItems(Alignment.CENTER);
    return register;
}
Also used : Component(com.vaadin.flow.component.Component) Composite(com.vaadin.flow.component.Composite) EmailField(com.vaadin.flow.component.textfield.EmailField) H1(com.vaadin.flow.component.html.H1) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) PageTitle(com.vaadin.flow.router.PageTitle) Route(com.vaadin.flow.router.Route) Alignment(com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment) Button(com.vaadin.flow.component.button.Button) PasswordField(com.vaadin.flow.component.textfield.PasswordField) MainLayout(com.example.application.views.MainLayout) AuthService(com.example.application.data.services.AuthService) TextField(com.vaadin.flow.component.textfield.TextField) Notification(com.vaadin.flow.component.notification.Notification) Button(com.vaadin.flow.component.button.Button) EmailField(com.vaadin.flow.component.textfield.EmailField) TextField(com.vaadin.flow.component.textfield.TextField) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) H1(com.vaadin.flow.component.html.H1) PasswordField(com.vaadin.flow.component.textfield.PasswordField)

Example 9 with PasswordField

use of com.vaadin.flow.component.textfield.PasswordField in project flow-components by vaadin.

the class PasswordFieldTest method autoselectPropertyValue.

@Test
public void autoselectPropertyValue() {
    PasswordField passwordField = new PasswordField();
    assertAutoselectPropertyValueEquals(passwordField, true);
    assertAutoselectPropertyValueEquals(passwordField, false);
}
Also used : PasswordField(com.vaadin.flow.component.textfield.PasswordField) Test(org.junit.Test)

Example 10 with PasswordField

use of com.vaadin.flow.component.textfield.PasswordField in project flow-components by vaadin.

the class PasswordFieldPage method addDisabledField.

private void addDisabledField() {
    PasswordField passwordField = new PasswordField();
    passwordField.setLabel("Password field label");
    passwordField.setPlaceholder("placeholder text");
    passwordField.setEnabled(false);
    passwordField.setId("disabled-password-field");
    Div message = new Div();
    message.setId("disabled-password-field-message");
    passwordField.addValueChangeListener(change -> message.setText("password changed"));
    add(passwordField, message);
}
Also used : Div(com.vaadin.flow.component.html.Div) PasswordField(com.vaadin.flow.component.textfield.PasswordField)

Aggregations

PasswordField (com.vaadin.flow.component.textfield.PasswordField)13 Test (org.junit.Test)4 Div (com.vaadin.flow.component.html.Div)3 Button (com.vaadin.flow.component.button.Button)2 EmailField (com.vaadin.flow.component.textfield.EmailField)2 TextField (com.vaadin.flow.component.textfield.TextField)2 AuthService (com.example.application.data.services.AuthService)1 MainLayout (com.example.application.views.MainLayout)1 Component (com.vaadin.flow.component.Component)1 Composite (com.vaadin.flow.component.Composite)1 H1 (com.vaadin.flow.component.html.H1)1 NativeButton (com.vaadin.flow.component.html.NativeButton)1 Notification (com.vaadin.flow.component.notification.Notification)1 Alignment (com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment)1 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)1 Select (com.vaadin.flow.component.select.Select)1 BigDecimalField (com.vaadin.flow.component.textfield.BigDecimalField)1 IntegerField (com.vaadin.flow.component.textfield.IntegerField)1 NumberField (com.vaadin.flow.component.textfield.NumberField)1 TextArea (com.vaadin.flow.component.textfield.TextArea)1