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(); } }
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(); } }
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(); } }); }
private void onFieldUpdated(FormField field, Object newValue) { if (!Objects.equals(workingInstance.get(field.getId()), newValue)) { workingInstance.set(field.getId(), newValue); validate(field); } }