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.

ServletIntegrationUI.java 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.vaadin.tests.integration;
  2. import com.vaadin.annotations.DesignRoot;
  3. import com.vaadin.server.ClassResource;
  4. import com.vaadin.server.Resource;
  5. import com.vaadin.server.VaadinRequest;
  6. import com.vaadin.ui.Label;
  7. import com.vaadin.ui.UI;
  8. import com.vaadin.ui.VerticalLayout;
  9. import com.vaadin.ui.declarative.Design;
  10. import com.vaadin.v7.data.Item;
  11. import com.vaadin.v7.ui.Table;
  12. public class ServletIntegrationUI extends UI {
  13. @Override
  14. protected void init(VaadinRequest request) {
  15. VerticalLayout layout = new VerticalLayout();
  16. layout.setMargin(true);
  17. setContent(layout);
  18. final Table table = new Table();
  19. table.addContainerProperty("icon", Resource.class, null);
  20. table.setItemIconPropertyId("icon");
  21. table.addContainerProperty("country", String.class, null);
  22. table.setRowHeaderMode(Table.RowHeaderMode.ICON_ONLY);
  23. table.setImmediate(true);
  24. table.setSelectable(true);
  25. table.setVisibleColumns(new Object[] { "country" });
  26. layout.addComponent(table);
  27. Item item = table.addItem("FI");
  28. item.getItemProperty("icon").setValue(new ClassResource("fi.gif"));
  29. item.getItemProperty("country").setValue("Finland");
  30. item = table.addItem("SE");
  31. item.getItemProperty("icon").setValue(new FlagSeResource());
  32. item.getItemProperty("country").setValue("Sweden");
  33. final Label selectedLabel = new LabelFromDesign();
  34. table.addValueChangeListener(event -> selectedLabel
  35. .setValue(String.valueOf(table.getValue())));
  36. layout.addComponent(selectedLabel);
  37. }
  38. @DesignRoot
  39. public static class LabelFromDesign extends Label {
  40. public LabelFromDesign() {
  41. Design.read(this);
  42. }
  43. }
  44. }