aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/customlayout/CustomLayoutUpdateCaption.java
blob: daf7a973a6b8755f7875be25ef549db6498d4ca8 (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
package com.vaadin.tests.components.customlayout;

import com.vaadin.annotations.Widgetset;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

@Widgetset("com.vaadin.DefaultWidgetSet")
public class CustomLayoutUpdateCaption extends UI {
    @Override
    protected void init(VaadinRequest vaadinRequest) {
        CustomLayout content = new CustomLayout();
        content.setTemplateContents("<div>\n"
                + "        <div location=\"test1\"></div>\n"
                + "        <div location=\"test2\"></div>\n"
                + "        <div location=\"okbutton\"></div>\n" + "</div>");
        content.setSizeUndefined();
        setContent(content);

        Button loginButton = new Button("Test");
        final TextField username1 = new TextField();
        final TextField username2 = new TextField();
        username1.setCaption("initial");
        username2.setCaption("initial");
        content.addComponent(username1, "test1");
        content.addComponent(new VerticalLayout(username2), "test2");
        content.addComponent(loginButton, "okbutton");

        loginButton.addClickListener(event -> {
            username1.setCaption("updated");
            username2.setCaption("updated");
        });
    }
}