예제 #1
0
 @SuppressWarnings("unchecked")
 boolean validate() {
   Map<String, Object> values = (Map<String, Object>) form.getValues();
   form.validate();
   if (!form.hasErrors()) {
     account.setIncludes((String) values.get("include"));
     account.setExcludes((String) values.get("exclude"));
     account.setDeleteFromMailbox(new Boolean(values.get("delete").toString()));
     account.setMailFolder((String) values.get("mailfolder"));
     account.setFormat(Integer.parseInt((String) values.get("format")));
     account.setStartDate((Date) values.get("startdate"));
   }
   return !form.hasErrors();
 }
예제 #2
0
  private void onSavePressed(DuengungRecord record, DynamicForm form, boolean addNewRecord) {
    // update the internal DTO values with the values stored in the form
    record.updateDTO(form.getValues());

    if (addNewRecord) {
      // save data and add to table
      this.dataManager.save(record, this.grid);
    } else {
      // save data and update table
      this.dataManager.update(record, this.grid);
    }

    // redraw the grid
    this.grid.redraw();
  }
예제 #3
0
 /**
  * Collect the changed fields on the form for sending to the backend for storage.
  *
  * @param fields
  * @return
  */
 @SuppressWarnings("unchecked")
 private LinkedHashMap<String, UIFormFieldValue> getChanges(
     DynamicForm form, LinkedList<String> fields) {
   LinkedHashMap<String, UIFormFieldValue> res = new LinkedHashMap<String, UIFormFieldValue>();
   LinkedHashMap<String, Object> formValues = (LinkedHashMap<String, Object>) form.getValues();
   for (String field : fields) {
     UIFormFieldValue oldFormField = dataMap.get(field);
     Object oldValue = oldFormField.getValue();
     Object newValue = formValues.get(field);
     if (newValue == null) {
       if (oldValue != null) res.put(field, null);
     } else if (!newValue.equals(oldValue)) {
       UIFormFieldValue newTO = new UIFormFieldValue();
       newTO.setValue(newValue); // , oldFormField.getType());
       res.put(field, newTO);
     }
   }
   return res;
 }