passwordField

passwordField defines a field for entering passwords. Characters typed into this field are masked by default.

For the login page, consider using a dedicated loginForm component that prompts a user password as a part of the authentication process.
  • XML element: passwordField

  • Java class: JmixPasswordField

Basics

The set of attributes of passwordField is similar to textField except there is no datatype attribute. The input for passwordField can only be of type String.

Basic passwordField example:

<passwordField id="passwordField"
               label="New password"
               required="true"
               clearButtonVisible="true"
               helperText="Make it strong!"/>
<button id="createPasswordButton"
        text="Create"/>
@ViewComponent
protected JmixPasswordField passwordField;
@Autowired
protected Notifications notifications;

@Subscribe("createPasswordButton")
protected void onButtonClick(ClickEvent<Button> event) {
    if (passwordField.getValue().isEmpty() == false)
        notifications.create("Password created")
                .show();
    }
password field basic

Attributes

Handlers

Чтобы сгенерировать заглушку обработчика в Jmix Studio, используйте вкладку Handlers панели инспектора Jmix UI, или команду Generate Handler, доступную на верхней панели контроллера экрана и через меню CodeGenerate (Alt+Insert / Cmd+N).

ChangeEvent

com.vaadin.flow.component.textfield.GeneratedVaadinTextField.ChangeEvent corresponds to the change DOM event.

InvalidChangeEvent

com.vaadin.flow.component.textfield.GeneratedVaadinTextField.InvalidChangeEvent is sent when the value of the invalid attribute of the component changes.

validator

Adds a validator instance to the component. The validator must throw ValidationException if the value is not valid.

@Install(to = "passwordField", subject = "validator")
private void passwordFieldValidator(String value) {
    if (value != null && String.valueOf(value).length() < 8)
        throw new ValidationException("Password must be at least 8 characters long");
}

Elements

See Also

See Vaadin Docs for more information.