After a page submit, I need to identify if any components on the page failed
validation. I’ve come up with two possible solutions, but they both seem to
be workarounds and I'm not 100% they cover all conditions.
1. Traverse the page’s component hierarchy using a custom visitor.
protected final boolean isFormComponentsValid() {
final Object traversalValObj = visitChildren(new
ValidFormComponentVisitor());
if (traversalValObj == IVisitor.STOP_TRAVERSAL) {
return false;
}
return true;
}
public final class ValidFormComponentVisitor implements IVisitor {
public Object component(final Component component) {
if (component instanceof FormComponent) {
if (!((FormComponent) component).isValid()) {
return IVisitor.STOP_TRAVERSAL;
}
}
return IVisitor.CONTINUE_TRAVERSAL;
}
}
2. Traverse the feedback messages in search of an ERROR.
public static final boolean isValidationError() {
final Iterator<FeedbackMessage> messageIterator =
Session.get().getFeedbackMessages().iterator();
while (messageIterator.hasNext()) {
final FeedbackMessage feedbackMessage =
messageIterator.next();
if (feedbackMessage.getLevel() ==
FeedbackMessage.ERROR) {
return true;
}
}
return false;
}
Is there anything directly built into the framework that will provide me
with this information? Any other ideas will be appreciated.
Thanks!
Louis
--
View this message in context:
http://www.nabble.com/How-to-identify-if-any-of-a-page%27s-components-failed-validation-after-a-submit-tp18599562p18599562.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]