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.

TablePageLengthUpdate.java 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package com.vaadin.tests.components.table;
  2. import com.vaadin.tests.components.TestBase;
  3. import com.vaadin.ui.Button;
  4. import com.vaadin.ui.Label;
  5. import com.vaadin.v7.data.util.MethodProperty;
  6. import com.vaadin.v7.ui.Table;
  7. import com.vaadin.v7.ui.TextField;
  8. public class TablePageLengthUpdate extends TestBase {
  9. private Label pageLengthLabel;
  10. private Table table;
  11. @Override
  12. protected String getDescription() {
  13. return "When the height is set for a table, the pagelength should be updated according to what is actually displayed. The table pagelength is initially 100 and the height is 100px. After clicking update the pageLength label should display the correct value (?).";
  14. }
  15. @Override
  16. protected Integer getTicketNumber() {
  17. return 1623;
  18. }
  19. @Override
  20. protected void setup() {
  21. table = new Table();
  22. table.setWidth("400px");
  23. table.setHeight("100px");
  24. table.setPageLength(100);
  25. table.addContainerProperty("p1", String.class, null);
  26. table.addContainerProperty("p2", String.class, null);
  27. table.addContainerProperty("p3", String.class, null);
  28. for (int i = 0; i < 10; i++) {
  29. table.addItem(new Object[] { "a" + i, "b" + i, "c" + i }, "" + i);
  30. }
  31. addComponent(table);
  32. pageLengthLabel = new Label("");
  33. updatePageLengthLabel();
  34. addComponent(pageLengthLabel);
  35. Button updateButton = new Button("Update pageLength",
  36. event -> updatePageLengthLabel());
  37. addComponent(updateButton);
  38. TextField tableHeight = new TextField("Table height",
  39. new MethodProperty<String>(this, "tableHeight"));
  40. tableHeight.setImmediate(true);
  41. addComponent(tableHeight);
  42. }
  43. public String getTableHeight() {
  44. return "" + (int) table.getHeight()
  45. + table.getHeightUnits().getSymbol();
  46. }
  47. public void setTableHeight(String height) {
  48. table.setHeight(height);
  49. }
  50. protected void updatePageLengthLabel() {
  51. pageLengthLabel.setValue("Pagelength: " + table.getPageLength());
  52. }
  53. }