Exemplo n.º 1
0
  void handleSaveButtonClicked() {
    getUi().getForm().commit();
    @SuppressWarnings("unchecked")
    BeanItem<Company> companyBeanItem = (BeanItem<Company>) getUi().getForm().getItemDataSource();
    Company company = companyBeanItem.getBean();

    /**
     * Avoid duplicate entry for the same email address. This has to be checked programatically as
     * GAE does not support unique constraints
     */
    if (company.getId() == null && isCompanyExisting(company.getCname())) {
      getUi().showError(Lang.getMessage("DuplicateEntryMsg", "cname"), null);
      return;
    }

    // Encrypt and set the password, only if a new one is given
    // TODO fix me
    if (company.getNewPassword() != null && company.getNewPassword().length() > 0) {
      String hashedPassword = PasswordUtil.generateHashedPassword(company.getNewPassword());
      company.setPassword(hashedPassword);
    }

    try {
      // Store the Company
      FacadeFactory.getFacade().store(company);

    } catch (Exception e) {
      getUi().showError(Lang.getMessage("ChangesSaveFailedMsg"), "Details: " + e.getMessage());
    }
    updateTable();
  }
Exemplo n.º 2
0
 void handleDeleteButtonClicked() {
   getUi()
       .showConfirmation(
           "", Lang.getMessage("ConfirmDeleteMsg"), new ConfirmDeleteCompanyDialogListener());
 }