示例#1
0
 private void validate(FormField field) {
   String value = (String) workingInstance.get(field.getId());
   FieldContainer container = containers.get(field.getId());
   if (field.isRequired() && Strings.isNullOrEmpty(value)) {
     container.setInvalid(I18N.CONSTANTS.requiredFieldMessage());
   } else {
     container.setValid();
   }
 }
示例#2
0
  private void setValue(FormInstance instance) {
    this.instance = instance;
    this.workingInstance = viewModel.getInstance().copy();

    for (Map.Entry<Cuid, FieldContainer> entry : containers.entrySet()) {
      FieldContainer container = entry.getValue();
      FormFieldWidget fieldWidget = container.getFieldWidget();
      fieldWidget.setValue(workingInstance.get(entry.getKey()));
      container.setValid();
    }
  }
示例#3
0
  public Promise<Void> persist(final FormInstance siteInstance) {

    int activityId = CuidAdapter.getLegacyIdFromCuid(siteInstance.getClassId());
    return dispatcher
        .execute(new GetSchema())
        .then(new SiteBindingFactory(activityId))
        .join(
            new Function<SiteBinding, Promise<Void>>() {
              @Nullable
              @Override
              public Promise<Void> apply(@Nullable SiteBinding binding) {
                return persist(binding, siteInstance).thenDiscardResult();
              }
            });
  }
示例#4
0
 private void onFieldUpdated(FormField field, Object newValue) {
   if (!Objects.equals(workingInstance.get(field.getId()), newValue)) {
     workingInstance.set(field.getId(), newValue);
     validate(field);
   }
 }