Exemplo n.º 1
0
  @Override
  public Promise<Void> show(FormViewModel viewModel) {
    this.viewModel = viewModel;

    try {
      addFormElements(viewModel.getFormClass(), 0);
      setValue(viewModel.getInstance());

      return Promise.done();

    } catch (Throwable caught) {
      return Promise.rejected(caught);
    }
  }
Exemplo n.º 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();
    }
  }
Exemplo n.º 3
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);
 }