@PostConstruct
  protected void init() {
    list.setHeight(25, Unit.PERCENTAGE);
    addComponent(
        new MVerticalLayout(new MHorizontalLayout(addNew, edit, delete), list)
        // .expand(list)
        );

    listEntities();
    list.addMValueChangeListener(e -> adjustActionButtonState());
  }
Esempio n. 2
0
  @PostConstruct
  public void init() {

    /*
     * Add value change listener to table that opens the selected Payee into
     * an editor.
     */
    payeeTable.addMValueChangeListener(
        new MValueChangeListener<Payee>() {

          @Override
          public void valueChange(MValueChangeEvent<Payee> event) {
            editPayee(event.getValue());
          }
        });

    /*
           * Configure the filter input and hook to text change events to
           * repopulate the table based on given filter. Text change
           * events are sent to the server when e.g. user holds a tiny pause
           * while typing or hits enter.
           *
          filter.setInputPrompt("Filter Payees...");
          filter.addTextChangeListener(new FieldEvents.TextChangeListener() {
              @Override
              public void textChange(FieldEvents.TextChangeEvent textChangeEvent) {
                  listPayees(textChangeEvent.getText());
              }
          });
    */

    /* "Responsive Web Design" can be done with plain Java as well. Here we
     * e.g. do selective layouting and configure visible columns in
     * table based on available width */
    layout();
    adjustTableColumns();
    /* If you wish the UI to adapt on window resize/page orientation
     * change, hook to BrowserWindowResizeEvent */
    UI.getCurrent().setResizeLazy(true);
    Page.getCurrent()
        .addBrowserWindowResizeListener(
            new Page.BrowserWindowResizeListener() {
              @Override
              public void browserWindowResized(
                  Page.BrowserWindowResizeEvent browserWindowResizeEvent) {
                adjustTableColumns();
                layout();
              }
            });
    listPayees();
  }