@SuppressWarnings("unchecked")
private void validateChildren(List<UIComponent> children, UIApplication uiApp, WebuiRequestContext context) {
for (UIComponent uiChild : children) {
if (uiChild instanceof UIFormInputBase) {
UIFormInputBase uiInput = (UIFormInputBase) uiChild;
if (!uiInput.isValid()) {
continue;
}
List<Validator> validators = uiInput.getValidators();
if (validators == null) {
continue;
}
try {
for (Validator validator : validators) {
validator.validate(uiInput);
}
} catch (MessageException ex) {
uiApp.addMessage(ex.getDetailMessage());
context.setProcessRender(true);
} catch (Exception ex) {
// TODO: This is a critical exception and should be handle in the UIApplication
uiApp.addMessage(new ApplicationMessage(ex.getMessage(), null));
context.setProcessRender(true);
}
} else if (uiChild instanceof UIFormInputSet) {
UIFormInputSet uiInputSet = (UIFormInputSet) uiChild;
validateChildren(uiInputSet.getChildren(), uiApp, context);
} else if (uiChild instanceof UIFormMultiValueInputSet) {
UIFormMultiValueInputSet uiInput = (UIFormMultiValueInputSet) uiChild;
List<Validator> validators = uiInput.getValidators();
if (validators == null) {
continue;
}
try {
for (Validator validator : validators) {
List<UIComponent> uiInputChild = uiInput.getChildren();
for (int i = 0; i < uiInputChild.size(); i++) {
try {
validator.validate((UIFormInput) uiInputChild.get(i));
} catch (MessageException ex) {
uiApp.addMessage(ex.getDetailMessage());
context.setProcessRender(true);
}
}
}
} catch (Exception ex) {
// TODO: This is a critical exception and should be handle in the UIApplication
uiApp.addMessage(new ApplicationMessage(ex.getMessage(), null));
context.setProcessRender(true);
}
} else if (uiChild instanceof UIFormInputContainer) {
UIFormInputContainer uiInput = (UIFormInputContainer) uiChild;
List<Validator> validators = uiInput.getValidators();
if (validators == null) {
continue;
}
try {
for (Validator validator : validators) {