You can specify default values for configuration interfaces properties. These values will be returned instead of null
if the property is not defined in the storage location – DB or app.properties
.
The default value can be specified as a string using @Default
annotation, or as a specific type using other annotations from com.haulmont.cuba.core.config.defaults
package:
@Property("cuba.email.adminAddress") @Default("address@company.com") String getAdminAddress(); @Property("cuba.email.delayCallCount") @Default("2") int getDelayCallCount(); @Property("cuba.email.defaultSendingAttemptsCount") @DefaultInt(10) int getDefaultSendingAttemptsCount(); @Property("cuba.test.dateProp") @Default("2013-12-12 00:00:00.000") @Factory(factory = DateFactory.class) Date getDateProp(); @Property("cuba.test.integerList") @Default("1 2 3") @Factory(factory = IntegerListTypeFactory.class) List<Integer> getIntegerList(); @Property("cuba.test.stringList") @Default("aaa|bbb|ccc") @Factory(factory = StringListTypeFactory.class) List<String> getStringList();
Default value for entities is a string of {entity_name}-{id}-{optional_view_name}
type, for example:
@Default("sec$User-98e5e66c-3ac9-11e2-94c1-3860770d7eaf-browse") User getAdminUser(); @Default("sec$Role-a294aef0-3ac9-11e2-9433-3860770d7eaf") Role getAdminRole();