コード例 #1
0
ファイル: ItemForm.java プロジェクト: pmoessner/firestorm-app
  // TODO (after ERRAI-366): make this method package-private
  @EventHandler("saveButton")
  public void onSaveButtonClicked(ClickEvent event) {
    TypedQuery<Department> deptQuery = em.createNamedQuery("departmentByName", Department.class);
    deptQuery.setParameter("name", department.getText());
    Department resolvedDepartment;
    List<Department> resultList = deptQuery.getResultList();
    if (resultList.isEmpty()) {
      resolvedDepartment = new Department();
      resolvedDepartment.setName(department.getText());
    } else {
      resolvedDepartment = resultList.get(0);
    }
    Item item = itemBinder.getModel();
    item.setDepartment(resolvedDepartment);
    item.setAddedBy(user);
    item.setAddedOn(new Date());

    fooList.getItems().add(item);
    em.persist(fooList);
    em.flush();

    if (afterSaveAction != null) {
      afterSaveAction.run();
    }
  }
コード例 #2
0
ファイル: ItemForm.java プロジェクト: pmoessner/firestorm-app
 public void setItem(Item item) {
   if (item.getDepartment() == null) {
     item.setDepartment(new Department());
   }
   itemBinder.setModel(item, InitialState.FROM_MODEL);
 }