Java Code Examples for com.vaadin.flow.component.textfield.TextArea#setValueChangeMode()

The following examples show how to use com.vaadin.flow.component.textfield.TextArea#setValueChangeMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AttributesView.java    From radman with MIT License 4 votes vote down vote up
AttributeEditDialog(AttributeService attributeService, UpdateListener<T> updateListener) {
    this.attributeService = attributeService;

    FormLayout formLayout = new FormLayout();
    formLayout.add(new H3(getDialogTitle()));
    TextArea description = new TextArea("Description");
    description.setValueChangeMode(ValueChangeMode.EAGER);
    description.setWidthFull();

    binder = new Binder<>(getClazz());
    binder.forField(description).bind(AttributeDto::getDescription, AttributeDto::setDescription);

    Button cancelBtn = new Button("Cancel", event -> setOpened(false));
    Button saveBtn = new Button("Save", event -> {
        BinderValidationStatus<T> validationStatus = binder.validate();
        if (validationStatus.isOk()) {
            try {
                T attributeDto = binder.getBean();
                attributeDto = save(attributeDto);
                updateListener.onUpdated(this, attributeDto);
                setOpened(false);
            } catch (Exception e) {
                log.warn("Failed to update attribute. Reason = '{}'", e.getMessage());
                ErrorNotification.show("Error",
                        "Ooops, something went wrong, try again please");
            }
        }
    });

    HorizontalLayout controlsLayout = new HorizontalLayout();
    controlsLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.END);
    controlsLayout.setWidthFull();
    controlsLayout.add(cancelBtn);
    controlsLayout.add(saveBtn);

    formLayout.add(description);
    formLayout.add(new Hr());
    formLayout.add(controlsLayout);
    formLayout.setMaxWidth("500px");
    add(formLayout);
}
 
Example 2
Source File: NasView.java    From radman with MIT License 4 votes vote down vote up
NasFormDialog(NasService nasService) {
    this.nasService = nasService;

    TextField name = new TextField("Name");
    name.setValueChangeMode(ValueChangeMode.EAGER);
    TextField shortName = new TextField("Short name");
    shortName.setValueChangeMode(ValueChangeMode.EAGER);
    TextField type = new TextField("Type");
    type.setValueChangeMode(ValueChangeMode.EAGER);
    NumberField port = new NumberField("Port");
    port.setValueChangeMode(ValueChangeMode.EAGER);
    PasswordField secret = new PasswordField("Secret");
    secret.setValueChangeMode(ValueChangeMode.EAGER);
    TextField server = new TextField("Server");
    server.setValueChangeMode(ValueChangeMode.EAGER);
    TextField community = new TextField("Community");
    community.setValueChangeMode(ValueChangeMode.EAGER);
    TextArea description = new TextArea("Description");
    description.setValueChangeMode(ValueChangeMode.EAGER);

    FormLayout formLayout = new FormLayout();
    formLayout.setWidthFull();
    formLayout.setMaxWidth("700px");
    formLayout.add(name, shortName, server, port, secret, type, community, description);
    formLayout.setResponsiveSteps(
            new FormLayout.ResponsiveStep("0px", 1),
            new FormLayout.ResponsiveStep("450px", 2));

    HorizontalLayout controlsLayout = new HorizontalLayout();
    controlsLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.END);
    controlsLayout.add(new Button("Cancel", event -> setOpened(false)));
    controlsLayout.add(getConfirmBtn());
    controlsLayout.setWidthFull();

    add(new H3(getDialogTitle()));
    add(formLayout);
    add(new Hr());
    add(controlsLayout);

    binder = new BeanValidationBinder<>(NasDto.class);
    binder.bind(name, "nasName");
    binder.bind(shortName, "shortName");
    binder.bind(type, "type");
    binder.forField(port)
            .withConverter(new DoubleToIntegerConverter("Port must be number " +
                    "between 1 and " + 65535 + "."))
            .bind("ports");
    binder.bind(secret, "secret");
    binder.bind(server, "server");
    binder.bind(community, "community");
    binder.bind(description, "description");
}