You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestBeanItemContainerUsage.java 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package com.vaadin.tests.components.beanitemcontainer;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import com.vaadin.tests.components.TestBase;
  5. import com.vaadin.v7.data.util.BeanItemContainer;
  6. import com.vaadin.v7.ui.Table;
  7. public class TestBeanItemContainerUsage extends TestBase {
  8. @Override
  9. protected String getDescription() {
  10. return "A test for the BeanItemContainer. The table should contain three persons and show their first and last names and their age.";
  11. }
  12. @Override
  13. protected Integer getTicketNumber() {
  14. return 1061;
  15. }
  16. @Override
  17. protected void setup() {
  18. Table t = new Table("Table containing Persons");
  19. t.setPageLength(5);
  20. t.setWidth("100%");
  21. List<Person> persons = new ArrayList<>();
  22. persons.add(new Person("Jones", "Birchman", 35));
  23. persons.add(new Person("Marc", "Smith", 30));
  24. persons.add(new Person("Greg", "Sandman", 75));
  25. BeanItemContainer<Person> bic = new BeanItemContainer<>(persons);
  26. t.setContainerDataSource(bic);
  27. addComponent(t);
  28. }
  29. public static class Person {
  30. private String firstName;
  31. private String lastName;
  32. private int age;
  33. public String getFirstName() {
  34. return firstName;
  35. }
  36. public void setFirstName(String firstName) {
  37. this.firstName = firstName;
  38. }
  39. public String getLastName() {
  40. return lastName;
  41. }
  42. public void setLastName(String lastName) {
  43. this.lastName = lastName;
  44. }
  45. public int getAge() {
  46. return age;
  47. }
  48. public void setAge(int age) {
  49. this.age = age;
  50. }
  51. public Person(String firstName, String lastName, int age) {
  52. super();
  53. this.firstName = firstName;
  54. this.lastName = lastName;
  55. this.age = age;
  56. }
  57. }
  58. }