Use the getAlerts method to validate field values

After configuring a component using your custom source configuration type and saving 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 user interface. The default implementation of this method returns no messages.

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");
}

For details, see the Javadoc and the provided example.

Back to top