RadDataForm: Built-in Editors

The RadDataForm contains many built-in property editors that are either automatically resolved depending on the property's type or by the associated annotation @DataFormProperty editor. The RadDataForm currently ships with the following built-in editors:

Using @DataFormProperty

The RadDataForm 'annotations' can be used to easily assign an editor to a property of the set Entity. The next example demonstrates how to set the editor of a property via the described annotations:

@DataFormProperty(
        label = "From",
        index = 0,
        editor = DataFormRadAutoCompleteEditor.class
)
public String[] getFrom() {
    return from;
}
public void setFrom(String[] value) {
    from = value;
    notifyListeners("From", value);
}

Using the 'DataFormRadAutoCompleteEditor'

The DataFormRadAutoCompleteEditor is a bit more advanced editor which provides an out of the box quick search functionality. This editor uses the RadAutoCompleteTextView stand alone element and all its functionality like DisplayMode is available to the RadDataForm editor.

Setting the suggestions 'source'

Because of the nature of the RadAutoCompleteTextView the editor which exposes its functionality requires some additional data to be passed to it which will be used as the 'suggestions' when a user starts typing in its text box.

Passing this data can be done in multiple different approaches depending on which one is the easiest for your scenario:

Setting the DisplayMode

If you are familiar with the RadAutoCompleteTextView element you know that is supports out of the box two different selected items display modes:

When using the DataFormRadAutoCompleteEditor you too have the option to change the editor's displayMode by simply calling its setDisplayMode() and passing the desired mode:

fromEditor.setDisplayMode(DisplayMode.TOKENS);

When the displayMode is set to TOKEN if the bound to that editor property of your EntityProperty is of type String[] and each of its elements is present in the "suggestion source" those items from the array will be rendered as separate tokens.

The full Java source code of the above example can be found here.