Ejemplo n.º 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();
   }
 }
Ejemplo n.º 2
0
 private void addField(final FormField field) {
   FormTree.Node node = viewModel.getFormTree().getRootField(field.getId());
   FormFieldWidget widget =
       widgetFactory.createWidget(
           viewModel,
           node,
           new ValueUpdater() {
             @Override
             public void update(Object value) {
               onFieldUpdated(field, value);
             }
           });
   FieldContainer container = containerFactory.createContainer(field, widget);
   containers.put(field.getId(), container);
   panel.add(container);
 }
Ejemplo n.º 3
0
 private void onFieldUpdated(FormField field, Object newValue) {
   if (!Objects.equals(workingInstance.get(field.getId()), newValue)) {
     workingInstance.set(field.getId(), newValue);
     validate(field);
   }
 }