-
Notifications
You must be signed in to change notification settings - Fork 51
Fields reordering and filtering
FXForm2 uses the FieldFilter
interface to filter the fields provided by the reflection service. These filters can be added dynamically by invoking the addFilter(FieldFilter... filters)
method on your form. Filters are applied sequentially -in the order they have been added to the form- to the original list of fields.
You can define your own filters by implementing the FieldFilter
interface. However, FXForm2 comes with some useful filters:
The ExcludeFilter
is used to prevent fields from being included in the form. Specify the name of the fields to exclude to the filter instance:
fxForm.addFilters(new ExcludeFilter("age", "mail"));
You can also simply exclude fields from the form by annotating theml with the @NonVisual annotation. This will configure a NonVisualFilter
which is loaded by default by the form.
public class DemoObject {
private StringProperty name = new StringProperty();
@NonVisual
private StringProperty shouldNotBeInTheForm = new StringProperty();
}
The IncludeFilter
is used to specify a list of fields to be included in the form. All other fields will be excluded. Specify the name of the fields to be included to the filter instance:
fxForm.addFilters(new IncludeFilter("age", "mail"));
The ReorderFilter
is used to reorder the fields of the form. Specify the name of the fields in the order you want to see them in your form. Fields that are not targeted in this list will be added at the end of the form.
fxForm.addFilters(new ReorderFilter("age", "mail"));