aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java
blob: 6c7b1129103cac7cf8b049d38e32f0fd1bdc9da2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.vaadin.tests.layouts;

import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.TextArea;

public class FormLayoutWithInvisibleComponent extends TestBase {

    private TextArea messages;

    @Override
    protected String getDescription() {
        return "There is an initial invisible text field below the checkbox. Checking the checkbox should show the field as a textarea (40x10) and also show its caption(\"Messages visible\") and a required error (*).";
    }

    @Override
    protected Integer getTicketNumber() {
        return 2706;
    }

    @Override
    protected void setup() {
        FormLayout formLayout = new FormLayout();
        CheckBox control = new CheckBox("Messages On/Off");
        control.addValueChangeListener(event -> {
            messages.setVisible(event.getValue());
            messages.setRequiredIndicatorVisible(true);
            messages.setCaption("Messages visible");
        });
        formLayout.addComponent(control);

        messages = new TextArea("Messages hidden");
        messages.setRows(10);
        messages.setWidth("40em");
        messages.setVisible(false);
        messages.setEnabled(false);
        formLayout.addComponent(messages);

        addComponent(formLayout);
    }

}