Search code examples
fieldtitleform-dataeclipse-scout

Scout Eclipse Neon set title of the field label in form data


I am wondering if you could set title of field in form data on server side.

Use case for this is that you have one field, and depend on some server logic you would set title of the field. Is it posible to set it on server somehow, to not sending string value to client and then set the title.

I was looking at method

formData.getMyField.setPropertyByClass(c, v);

but I don't know if this method could do this and which property I need to set.


Solution

  • FormData classes can contain two types of data holder classes:

    1. data holders for values associated with value fields (these holders always extend AbstractValueFieldData) and
    2. data holders for values associated with form data properties (these holders always extend AbstractPropertyData).

    A form data property is generated if the associated form has a member variable whose setter and getter is annotated with @FormData.

    The method setPropertyByClass(...) is intended to set the value of a form data property in a form data object. The method cannot be used to set the label of a form.

    The standard way to set the label of a field would be to load the form data from the server and to set the label afterwards, as in the following code snippet:

    ...
    public class ModifyHandler extends AbstractFormHandler {
      MyFormData formData = SERVICES.getService(IMyProcessService.class).load();
      importFormData(formData);
      getMyField.setLabel(formData.getMyProperty().getValue());
    }
    ...