Search in sources :

Example 31 with TextArea

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

the class ChangeObjectPassword method buildFields.

@Override
protected void buildFields() {
    addField(objectField);
    setRequired(objectField);
    trackValueChange(objectField);
    addField(password = createPasswordField("Current Password"));
    password.setVisible(false);
    addField(newPassword = createPasswordField("New Password"));
    addField(repeatNewPassword = createPasswordField("Repeat New Password"));
    TextArea conditon = new TextArea();
    conditon.setValue(PasswordPolicy.getForClass(objectField.getObjectClass()).describe());
    conditon.setReadOnly(true);
    add(conditon);
}
Also used : TextArea(com.vaadin.flow.component.textfield.TextArea)

Example 32 with TextArea

use of com.vaadin.flow.component.textfield.TextArea in project komunumo-server by komunumo.

the class MailTemplateDialog method createForm.

@Override
public void createForm(@NotNull final FormLayout formLayout, @NotNull final Binder<MailTemplateRecord> binder) {
    final var id = new Select<>(mailTemplateIds.stream().map(MailTemplateId::name).toArray(String[]::new));
    id.setRequiredIndicatorVisible(true);
    id.setLabel("ID");
    formLayout.add(id);
    final var subject = new TextField("Subject");
    subject.setRequiredIndicatorVisible(true);
    subject.setValueChangeMode(EAGER);
    formLayout.add(subject);
    final var contentText = new TextArea();
    contentText.setRequiredIndicatorVisible(true);
    formLayout.add(new CustomLabel("Content as plain text"), contentText);
    final var contentHTML = new RichTextEditor();
    contentHTML.setRequiredIndicatorVisible(true);
    formLayout.add(new CustomLabel("Content as formatted HTML"), contentHTML);
    binder.forField(id).withValidator(Objects::nonNull, "Please select the ID").bind(MailTemplateRecord::getId, MailTemplateRecord::setId);
    binder.forField(subject).withValidator(new StringLengthValidator("Please enter the subject (max. 255 chars)", 1, 255)).bind(MailTemplateRecord::getSubject, MailTemplateRecord::setSubject);
    binder.forField(contentText).withValidator(new StringLengthValidator("Please enter the content as plain text (max. 8'000 chars)", 1, 8_000)).bind(MailTemplateRecord::getContentText, MailTemplateRecord::setContentText);
    binder.forField(contentHTML.asHtml()).withValidator(new StringLengthValidator("Please enter the content as formattet HTML (max. 8'000 chars)", 1, 8_000)).bind(MailTemplateRecord::getContentHtml, MailTemplateRecord::setContentHtml);
    afterOpen = () -> id.setReadOnly(id.getValue() != null);
}
Also used : CustomLabel(org.komunumo.ui.component.CustomLabel) MailTemplateId(org.komunumo.data.entity.MailTemplateId) TextArea(com.vaadin.flow.component.textfield.TextArea) StringLengthValidator(com.vaadin.flow.data.validator.StringLengthValidator) Select(com.vaadin.flow.component.select.Select) TextField(com.vaadin.flow.component.textfield.TextField) RichTextEditor(com.vaadin.flow.component.richtexteditor.RichTextEditor) MailTemplateRecord(org.komunumo.data.db.tables.records.MailTemplateRecord)

Example 33 with TextArea

use of com.vaadin.flow.component.textfield.TextArea in project komunumo-server by komunumo.

the class MembersView method createFeedbackForm.

private Component createFeedbackForm() {
    final var div = new Div();
    div.addClassName("feedback-form");
    div.add(new H2("Your Feedback, suggestion, idea..."));
    final var firstName = new TextField("First name");
    firstName.setMinLength(1);
    firstName.setMaxLength(2_000);
    final var lastName = new TextField("Last name");
    lastName.setMinLength(1);
    lastName.setMaxLength(2_000);
    final var email = new EmailField("Email");
    email.setMinLength(1);
    email.setMaxLength(2_000);
    final var feedback = new TextArea("Feedback");
    feedback.setMinLength(1);
    feedback.setMaxLength(2_000);
    final var submit = new Button("Send");
    submit.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
    submit.setEnabled(false);
    submit.setDisableOnClick(true);
    List.of(firstName, lastName, email, feedback).forEach(field -> {
        field.setRequiredIndicatorVisible(true);
        field.setValueChangeMode(ValueChangeMode.EAGER);
        field.addValueChangeListener(valueChangeEvent -> submit.setEnabled(!firstName.getValue().isBlank() && !lastName.getValue().isBlank() && !email.isInvalid() && !feedback.getValue().isBlank()));
    });
    final var form = new FormLayout();
    form.setResponsiveSteps(new FormLayout.ResponsiveStep("0", 1));
    form.add(firstName, lastName, email, feedback, submit);
    div.add(form);
    submit.addClickListener(buttonClickEvent -> {
        databaseService.receiveFeedback(firstName.getValue(), lastName.getValue(), email.getValue(), feedback.getValue());
        div.replace(form, new Paragraph("We have received your feedback, thank you very much!"));
    });
    firstName.focus();
    return div;
}
Also used : Div(com.vaadin.flow.component.html.Div) FormLayout(com.vaadin.flow.component.formlayout.FormLayout) TextArea(com.vaadin.flow.component.textfield.TextArea) Button(com.vaadin.flow.component.button.Button) EmailField(com.vaadin.flow.component.textfield.EmailField) TextField(com.vaadin.flow.component.textfield.TextField) H2(com.vaadin.flow.component.html.H2) Paragraph(com.vaadin.flow.component.html.Paragraph)

Example 34 with TextArea

use of com.vaadin.flow.component.textfield.TextArea in project linkki by linkki-framework.

the class BindPlaceholderAspectDefinitionTest method testPlaceholderType_AutoFilledPlaceholder.

@Test
void testPlaceholderType_AutoFilledPlaceholder() {
    TextArea area = new TextArea();
    callPlaceholderAspectDefinition(area, "I am a placeholder", PlaceholderType.AUTO);
    String suffixResult = area.getPlaceholder();
    assertThat(suffixResult).isEqualTo("I am a placeholder");
}
Also used : TextArea(com.vaadin.flow.component.textfield.TextArea) Test(org.junit.jupiter.api.Test)

Example 35 with TextArea

use of com.vaadin.flow.component.textfield.TextArea in project linkki by linkki-framework.

the class BindReadOnlyAspectDefinitionTest method createWritableComponent.

private HasValue<?, ?> createWritableComponent() {
    TextArea text = new TextArea();
    text.setReadOnly(false);
    return text;
}
Also used : TextArea(com.vaadin.flow.component.textfield.TextArea)

Aggregations

TextArea (com.vaadin.flow.component.textfield.TextArea)52 TextField (com.vaadin.flow.component.textfield.TextField)14 Test (org.junit.jupiter.api.Test)13 Div (com.vaadin.flow.component.html.Div)8 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)6 Test (org.junit.Test)6 Button (com.vaadin.flow.component.button.Button)5 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)5 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)4 FormLayout (com.vaadin.flow.component.formlayout.FormLayout)4 H3 (com.vaadin.flow.component.html.H3)3 EmailField (com.vaadin.flow.component.textfield.EmailField)3 NumberField (com.vaadin.flow.component.textfield.NumberField)3 ValueChangeEvent (com.vaadin.flow.component.HasValue.ValueChangeEvent)2 ResponsiveStep (com.vaadin.flow.component.formlayout.FormLayout.ResponsiveStep)2 H2 (com.vaadin.flow.component.html.H2)2 NativeButton (com.vaadin.flow.component.html.NativeButton)2 StringLengthValidator (com.vaadin.flow.data.validator.StringLengthValidator)2 Route (com.vaadin.flow.router.Route)2 EFieldTypeDefinition (ch.akros.marketplace.administration.constants.EFieldTypeDefinition)1