Use the CommonIntegrator getAlerts method to validate field values
After a user has configured a component using your custom source
configuration type and saved the component, you can use the
CommonIntegrator
method
getAlerts()
to validate the provided values.
If the values are invalid, you can return a collection of alert messages to the UI. The default implementation of this method returns nothing. Use this method as a way to prevent integration failures by prechecking all the required values.
An example implementation is as follows:
Private File location = null; public Collection<String> getAlerts(Locale locale) throws Exception { if(location == null) return Arrays.asList("The Base Directory cannot be empty"); File toCheck = new File(location); if(toCheck.exists()) return null; return Arrays.asList("The Base Directory does not exist"); }
See the Javadoc and the example for more details.