* @param obj
* @return
* @throws Exception
*/
public static FormValidator parseValidatorFromJsonObject(JSONObject obj) throws Exception {
FormValidator validator = null;
PluginManager pluginManager = (PluginManager) appContext.getBean("pluginManager");
if (!obj.isNull(FormUtil.PROPERTY_PROPERTIES)) {
JSONObject objProperty = obj.getJSONObject(FormUtil.PROPERTY_PROPERTIES);
if (!objProperty.isNull(FormUtil.PROPERTY_VALIDATOR)) {
String validatorStr = objProperty.getString(FormUtil.PROPERTY_VALIDATOR);
JSONObject validatorObj = new JSONObject(validatorStr);
// create validator object
if (!validatorObj.isNull(FormUtil.PROPERTY_CLASS_NAME)) {
String className = validatorObj.getString(FormUtil.PROPERTY_CLASS_NAME);
if (className != null && className.trim().length() > 0) {
validator = (FormValidator) pluginManager.getPlugin(className);
if (validator != null) {
// set child properties
Map<String, Object> properties = FormUtil.parsePropertyFromJsonObject(validatorObj);
validator.setProperties(properties);
}
}
}
}
}