Hello,
I have a field that I am trying to add a serverCustom validator, but when the validation fires, I don't get the error message displayed on the ListGrid.
The validator looks like this:
The validation in the datasource xml file looks like this:
Here's the editing:
But when I fire off the serverCustom validation, nothing shows up, though I see this in the log:
Here it is stuck in "Pending" after the validations fire:
It just sits there in a "Pending" state. So the ListGrid is prevented from saving the record.
This happens whether the serverCustom is Java based or in Groovy.
If I'm doing something wrong, please let me know. Maybe I'm missing a step.
Environment:
I have a field that I am trying to add a serverCustom validator, but when the validation fires, I don't get the error message displayed on the ListGrid.
The validator looks like this:
public class ServiceTypeValidator {
private static final Logger log = LoggerFactory.getLogger(ServiceTypeValidator.class);
@SuppressWarnings({"rawtypes", "unchecked"})
public boolean condition(Object value, Validator validator, String fieldName, Map record, DataSource ds, HttpSession session) throws Exception {
log.debug("ServiceTypeValidator");
// validator.addErrorMessageVariable("CODE", "Ouch");
return false;
}
}
private static final Logger log = LoggerFactory.getLogger(ServiceTypeValidator.class);
@SuppressWarnings({"rawtypes", "unchecked"})
public boolean condition(Object value, Validator validator, String fieldName, Map record, DataSource ds, HttpSession session) throws Exception {
log.debug("ServiceTypeValidator");
// validator.addErrorMessageVariable("CODE", "Ouch");
return false;
}
}
The validation in the datasource xml file looks like this:
<validators>
<validator type="required" />
<validator type="lengthRange" min="6" max="6" />
<validator type="serverCustom">
<serverObject className="net.someproject.smartclient.validators.ServiceTypeValidator" methodName="condition"/>
<errorMessage>I don't think so.</errorMessage>
</validator>
</validators>
The "required" and "lengthRange" validators both work fine: <validator type="required" />
<validator type="lengthRange" min="6" max="6" />
<validator type="serverCustom">
<serverObject className="net.someproject.smartclient.validators.ServiceTypeValidator" methodName="condition"/>
<errorMessage>I don't think so.</errorMessage>
</validator>
</validators>
Here's the editing:
But when I fire off the serverCustom validation, nothing shows up, though I see this in the log:
=== 2022-08-215 08:36:17.768 DEBUG ValidationContext - Adding validation errors at path '/L_PEC/CODE/CODE': {severity=ERROR, errorMessage=I don't think so.}
=== 2022-08-215 08:36:17.768 INFO Validation - Validation error: [
{
CODE:{
severity:"ERROR",
errorMessage:"I don't think so."
}
}
]
=== 2022-08-215 08:36:17.768 INFO Validation - Validation error: [
{
CODE:{
severity:"ERROR",
errorMessage:"I don't think so."
}
}
]
Here it is stuck in "Pending" after the validations fire:
It just sits there in a "Pending" state. So the ListGrid is prevented from saving the record.
This happens whether the serverCustom is Java based or in Groovy.
If I'm doing something wrong, please let me know. Maybe I'm missing a step.
Environment:
SmartClient Version: v12.1p_2021-11-02/Enterprise Deployment (built 2021-11-02)
Chrome version 103.0.5060.134 (Official Build) (x86_64)
Firefox 103.0 (64-bit)
Chrome version 103.0.5060.134 (Official Build) (x86_64)
Firefox 103.0 (64-bit)
Comment