You can throw a general exception from the setter of your attribute in the view object, but that is not enough, because this will look different (no 'red' field, and a different style of exception on the screen).
To solve this, you will need to throw an 'AttrValException', as shown below:
General method in the view row base class.
Final static String RESOURCE_BUNDLE_NAME = "my_resource_bundle";
protected void throwValidationException(String message, String attrName) {
PropertiesBundleDef resBundle = new PropertiesBundleDef(this.getViewDef());
resBundle.setPropertiesFile(RESOURCEBUNDLE_NAME);
throw new AttrValException(MetaObjectBase.TYP_VIEW_OBJECT, resBundle, message, getViewObject().getFullName(), attrName);
}
protected void throwValidationException(String message, String attrName) {
PropertiesBundleDef resBundle = new PropertiesBundleDef(this.getViewDef());
resBundle.setPropertiesFile(RESOURCEBUNDLE_NAME);
throw new AttrValException(MetaObjectBase.TYP_VIEW_OBJECT, resBundle, message, getViewObject().getFullName(), attrName);
}
Setter of view row object:
public void setMyCode(String value){
if(/* your validation logic */){
throwValidationException("myCodeValidationErrorMsgKey", "MyCode");
}
setAttributeInternal(MY_CODE, value);
}
if(/* your validation logic */){
throwValidationException("myCodeValidationErrorMsgKey", "MyCode");
}
setAttributeInternal(MY_CODE, value);
}