I would like to go through all fields in form data.
I know that in form I could do something like this :
// Go through all fields with IFormFieldVisitor
box.visitFields(new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField field, int level, int fieldIndex) {
if (field instanceof MyClass) {
...
}
return true;
}
}, 0);
but form data doesn't have this options. How to do this in form data.
You can obtain them using
AbstractFormData.getFields
to obtain the top-level fields. If you need nested fields as well, have a look at the more complex AbstractFormData.getAllFieldsRec()
.AbstractFormData.getAllProperties
to obtain properties that you have defined by annotating the getters and setters with @FormData
That was the simple case.
Now, if you are using the Scout Extension mechanism to add new elements to an existing form (and it's formdata), you will have to take those contributions into account. If you need to do this, you can refer to the source code of the AbstractForm.importFormData to see how Scout implements this.