/**
   * Returns all values filled in in the writable fields on the form.
   *
   * @throws InvalidValueException when a validation error occurs.
   */
  public Map<String, String> getFormPropertyValues() throws InvalidValueException {
    // Commit the form to ensure validation is executed
    form.commit();

    Map<String, String> formPropertyValues = new HashMap<String, String>();

    // Get values from fields defined for each form property
    for (FormProperty formProperty : formProperties) {
      if (formProperty.isWritable()) {
        Field field = form.getField(formProperty.getId());
        FormPropertyRenderer renderer = getRenderer(formProperty);
        String fieldValue = renderer.getFieldValue(formProperty, field);

        formPropertyValues.put(formProperty.getId(), fieldValue);
      }
    }
    return formPropertyValues;
  }
  public void setFormProperties(List<FormProperty> formProperties) {
    this.formProperties = formProperties;

    form.removeAllProperties();

    // Clear current components in the grid
    if (formProperties != null) {
      for (FormProperty formProperty : formProperties) {
        FormPropertyRenderer renderer = getRenderer(formProperty);

        Field editorComponent = renderer.getPropertyField(formProperty);
        if (editorComponent != null) {
          // Get label for editor component.
          form.addField(formProperty.getId(), editorComponent);
        }
      }
    }
  }