private void addValidation(FlowActivity activity, IRender render) {
if (render instanceof AbstractFormComponent && render instanceof ValidatableField) {
AbstractFormComponent formComponent = (AbstractFormComponent) render;
IBinding alreadyBinding = formComponent.getBinding(ALREADY_ADDED_BINDING);
if ( alreadyBinding == null) {
FlowPropertyDefinition definition = activity.getFlowPropertyDefinition(this.key);
if ( definition != null) {
IBinding validatorsBinding = formComponent.getBinding(VALIDATORS);
if (definition.isDynamic()) {
IBinding htmlClassBinding = formComponent.getBinding(HTML_CLASS);
IBinding htmlOnBlurBinding = formComponent.getBinding(HTML_ONBLUR);
String htmlClassToAdd = "refresh-" + formComponent.getClientId();
String htmlClass = null;
if ( htmlClassBinding == null) {
htmlClass= htmlClassToAdd;
} else if (htmlClassBinding instanceof LiteralBinding) {
htmlClass =(String)htmlClassBinding.getObject(String.class) + " "+htmlClassToAdd;
} else {
getLog().debug(activity.getFullActivityInstanceNamespace()+ ": cannot add class to component="+formComponent);
}
if (htmlClass != null) {
formComponent.setBinding(HTML_CLASS, new LiteralBinding("html class", valueConverter, location, htmlClass));
}
if (htmlOnBlurBinding == null) {
String htmlOnBlurValue = "javascript:amplafi.util.refreshIfChanged(this);";
formComponent.setBinding(HTML_ONBLUR, new LiteralBinding("html on blur", valueConverter, location, htmlOnBlurValue));
} else {
getLog().debug(activity.getFullActivityInstanceNamespace()+ ": cannot add onblur to component="+formComponent);
}
}
if (validatorsBinding == null) {
String validators = definition.getValidators();
if ( definition.getPropertyRequired() == FlowActivityPhase.advance) {
if ( isBlank(validators)) {
validators = REQUIRED;
} else {
// may re-add required if already present - seems like a minor issue
validators = REQUIRED + "," + validators;