Build-IT: Setting initial default values that remain after the form is cleared

The following feature has been added to the GenericSelectorForm: setting initial default values and setting default values after the form is cleared.

This feature might come in handy when you want to have some default values entered when a selector is shown, and when you want these default values to be retained after the clear button is clicked. Some similar features already exist (e.g. runFastProperties, @PropertyEvents, and the GenericSelectorFormWithReadOnlyFields class), but these don’t quite provide the desired functionality.

The new method is to add a GenericSelectorDefaultValuesProvider to your SelectorForm. This interface provides two methods:

/**
* Sets default values after clear command is called
* @param formModel
*/
void setDefaultValuesAfterClear(FormModel formModel);
/**
* Sets initial default values
* @param formModel
*/
void setInitialDefaultValues(FormModel formModel);

You have to create a class which implements this interface, and set it on your selectorformDescriptor bean, like this:


Note:
– For setDefaultValuesAfterClear(FormModel): Create a new FormObject, set the default values on it and set that new formObject on the specified FormModel. If you use FormModelUtils, or if you set the value on the existing formObject, you might get problems with the revert-icon.
– For setInitialDefaultValues(FormModel): You can use whatever method you like. Either use FormModelUtils, or update the existing FormObject, or create a new one.

Comments are closed.