aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/table/LongMultiselect.java
blob: 16111635d46e56db66c8de9dbb69533b4a5ee404 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.vaadin.tests.components.table;

import java.util.Collection;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.ui.Button;
import com.vaadin.v7.data.Property;
import com.vaadin.v7.ui.Table;

public class LongMultiselect extends AbstractReindeerTestUI {

    private enum ItemProperty {
        COLUMN1, COLUMN2
    }

    @Override
    protected void setup(VaadinRequest request) {
        final Table table = new Table("Ticket #8264 table");
        addComponent(table);

        table.setWidth("200px");
        table.setHeight("170px");
        table.setSelectable(true);
        table.setMultiSelect(true);
        table.setImmediate(true);

        // Create example data
        table.addContainerProperty(ItemProperty.COLUMN1, String.class, null);
        table.addContainerProperty(ItemProperty.COLUMN2, String.class, null);
        for (int i = 1; i < 100; i++) {
            table.addItem(new String[] { "Item " + i, null }, i);
        }

        // Add action button
        addComponent(new Button("Do It", event -> {
            // Set ItemProperty.COLUMN2 for all selected values of table
            Collection selectedIds = (Collection) table.getValue();
            for (final Object itemId : selectedIds) {
                final Property p = table.getItem(itemId)
                        .getItemProperty(ItemProperty.COLUMN2);
                if (p.getValue() instanceof String) {
                    p.setValue(null);
                } else {
                    p.setValue("updated");
                }
            }
        }));

    }

    @Override
    protected String getTestDescription() {
        return "Multiselecting 94 rows (from \"item 5\" to \"item 98\") and modifying second column of each row selected (press Do It). This should work (update the 2nd column) and not cause JS exception.";
    }

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