Example #1
0
  ComboBox userList() {
    users.setCaption("Users: ");
    users.setWidth("200px");
    users.setNullSelectionAllowed(false);
    users.addContainerProperty("y", String.class, "");
    users.setItemCaptionPropertyId("y");

    Item i;
    for (User u : service.getUserList()) {
      i = users.addItem(u.getId());
      i.getItemProperty("y").setValue(u.getUsername());
    }

    users.addListener(
        new ValueChangeListener() {

          @Override
          public void valueChange(Property.ValueChangeEvent event) {
            allowedBackwardInputAttendance.setValue(
                service.isUserAllowedToEnterPreviousAttendance(
                    util.convertStringToInteger(event.getProperty().getValue().toString())));
          }
        });

    users.setImmediate(true);

    return users;
  }
  private ComboBox createSelect(String caption) {
    final ComboBox cb = new ComboBox();
    cb.setImmediate(true);
    cb.addContainerProperty(CAPTION, String.class, "");
    cb.setItemCaptionPropertyId(CAPTION);
    cb.setCaption(caption);
    cb.addValueChangeListener(
        new ValueChangeListener() {

          @Override
          public void valueChange(ValueChangeEvent event) {
            Notification.show(
                "Value now:" + cb.getValue() + " " + cb.getItemCaption(cb.getValue()));
          }
        });
    return cb;
  }