I’m working on a gateway module that needs to store some properties as Persistence Records. I’m validating a StringField, and instead of throwing an exception that would cause the UI form to exit, I want to display a message on the feedback panel at the top of the form, to give the user a chance to fix the input. Something like this:
For context here is the snippet I am using:
public static final StringField FooBar = new StringField(META, "FooBar")
.addValidator(new SValidatorI() {
@Override
public void onValidate(SFieldMeta field, SRecordInstance instance) throws SException.Validation {
Boolean isEnabledValue = instance.getBoolean(isEnabled);
String foobarValue = instance.getString(field);
if (isEnabledValue && (foobarValue == null || foobarValue.trim().isEmpty())) {
throw new SException.Validation("Foo bar cannot be null or empty when enabled.");
}
}
});
Has anyone else encountered this before?