summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/tests/components/beanitemcontainer/TestBeanItemContainerUsage.java
blob: 20becea974ee295f91058232f363e6e6a82fa48d (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.vaadin.tests.components.beanitemcontainer;

import java.util.ArrayList;
import java.util.List;

import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Table;

public class TestBeanItemContainerUsage extends TestBase {

    @Override
    protected String getDescription() {
        return "A test for the BeanItemContainer. The table should contain three persons and show their first and last names and their age.";
    }

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

    @Override
    protected void setup() {
        Table t = new Table("Table containing Persons");
        t.setPageLength(5);
        t.setWidth("100%");
        List<Person> persons = new ArrayList<Person>();
        persons.add(new Person("Jones", "Birchman", 35));
        persons.add(new Person("Marc", "Smith", 30));
        persons.add(new Person("Greg", "Sandman", 75));

        BeanItemContainer<Person> bic = new BeanItemContainer<Person>(persons);
        t.setContainerDataSource(bic);

        addComponent(t);
    }

    public static class Person {
        private String firstName;
        private String lastName;
        private int age;

        public String getFirstName() {
            return firstName;
        }

        public void setFirstName(String firstName) {
            this.firstName = firstName;
        }

        public String getLastName() {
            return lastName;
        }

        public void setLastName(String lastName) {
            this.lastName = lastName;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }

        public Person(String firstName, String lastName, int age) {
            super();
            this.firstName = firstName;
            this.lastName = lastName;
            this.age = age;
        }

    }
}