コード例 #1
0
  public int updateAndValidateForm() {
    try {
      // 3.2 Masukkan nilai form yang valid(commit) ke dalam tabel >> dan database
      model.getBinderHeader().commit();
      model.getsMerkJpaService().updateObject(model.getItemHeader());

      view.getTable().refreshRowCache();

      // 3.3. atur kondisi status form
      view.setDisplay();
      model.setOperationStatus(EnumOperationStatus.EDITING.getStrCode());
      view.setFormButtonAndTextState();
      // 3.4. Refresh lagi container >> SUDAH TIDAK DIPERLUKAN LAGI OLEH KARENA OPERSI //3.2

      Notification.show("UPDATE Sukses!!!", Notification.TYPE_TRAY_NOTIFICATION);
      try {
        view.getTable().focus();
      } catch (Exception ex) {
      }

    } catch (Exception ex) {
      Notification.show("Terjadi Kesalahan Insert data!!!", Notification.TYPE_TRAY_NOTIFICATION);
      view.focustIdOrDesc();
      return 1;
    }
    return 0;
  }
コード例 #2
0
  public void addItem() {
    try {

      // 1. Deklarasikan object awal
      model.newItemHeader = new SMerk();
      // Karena tidak pisa pake null representation

      model.newItemHeader.setId("New");
      model.newItemHeader.setDescription("");

      // 2. SET NEW DATA ITEM TO BINDER
      model.getBinderHeader().setItemDataSource(model.newItemHeader);

      // 3. REFRESH VIEW AND SHOW FORM LAYOUT
      view.bindAndBuildFieldGroupComponent();
      view.getFormLayout().setVisible(true);

      // 3.SET FORM STATE AND BUTTON STATE
      model.setOperationStatus(EnumOperationStatus.ADDING.getStrCode());
      view.setFormButtonAndTextState();

    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
コード例 #3
0
  public int insertAndValidateForm() {
    boolean kodeValid = true;
    boolean inputValid = true;
    String theId = (String) view.getFieldId().getConvertedValue();

    if (theId.trim().equalsIgnoreCase("New")) {
      kodeValid = false;
      Notification.show("ID tidak boleh New!!", Notification.TYPE_TRAY_NOTIFICATION);
      view.focustIdOrDesc();
      return 1;
    }

    //		//VALIDASI KODE TIDAK DIPERLUKAN LAGI
    //		if (model.getfAreaJpaService().findAll(theId).size()>0){
    //			kodeValid = false;
    //			Notification.show("Kode Sudah Terpakai!!.");
    //			view.focustIdOrDesc();
    //			return 1;
    //		}

    // 2. Additional Validasi input di handle oleh form Validator
    // 3. Aksi Save
    if (kodeValid && inputValid) {
      try {
        // 3.1 commit form >> MASUKKAN KE DATABASE
        model.getBinderHeader().commit(); // COMMIT TETAP PAKE NEW TAPI CLIENT SIDE

        model.getsMerkJpaService().createObject(model.getNewItemHeader());

        // 3.2 Masukkan nilai form yang valid(commit) ke dalam tabel
        model.getBeanItemContainerHeader().addItem(model.getNewItemHeader());
        view.getTable().refreshRowCache();

        // 3.3. atur kondisi status form
        view.setDisplay();
        model.setOperationStatus(EnumOperationStatus.OPEN.getStrCode());
        view.setFormButtonAndTextState();
        // 3.4. Refresh lagi container >> SUDAH TIDAK DIPERLUKAN LAGI OLEH KARENA OPERSI //3.2

        Notification.show("Penambahan Sukses!!!", Notification.TYPE_TRAY_NOTIFICATION);
        try {
          view.getTable().focus();
        } catch (Exception ex) {
        }

      } catch (Exception ex) {
        Notification.show("Terjadi Kesalahan Insert data!!!", Notification.TYPE_TRAY_NOTIFICATION);
        view.focustIdOrDesc();
        ex.printStackTrace();
        return 1;
      }
    } else {
      return 2;
    }

    return 0;
  }
コード例 #4
0
  @Override
  public void itemClick(ItemClickEvent event) {
    Object itemId = event.getItemId();
    Item item = view.getTable().getItem(itemId);
    boolean entitySelected = item != null;
    // modify visibility of form and delete button if an item is selected
    view.getFormLayout().setVisible(entitySelected);
    view.getBtnDeleteForm().setEnabled(entitySelected);

    if (entitySelected) {

      model.itemHeader = new SMerk();
      model.itemHeader = model.getBeanItemContainerHeader().getItem(itemId).getBean();
      model.getBinderHeader().setItemDataSource(model.itemHeader);

      if (event.isDoubleClick()) {
        view.showWindowForm();
      }
    }

    view.bindAndBuildFieldGroupComponent();
    model.setOperationStatus(EnumOperationStatus.EDITING.getStrCode());
    view.setFormButtonAndTextState();
  }