@Override
protected void delegateSubmit(Button submittingButton) {
// Model was successfully updated with valid data
onSubmit();
if (!hasError()) {
visitChildren(new IFormSubmitAware.Visitor(this));
}
if (submittingButton != null &&!hasError())
{
submittingButton.onSubmit();
}
}
public interface IFormSubmitAware {
void onSubmit();
public static class Visitor implements IVisitor {
private final Form form;
public Visitor(Form form) {
if (form == null) {
throw new IllegalArgumentException("Argument [[form]] cannot be null");
}
this.form = form;
}
public Object component(Component<?> component) {
if (component instanceof IFormSubmitAware) {
((IFormSubmitAware)component).onSubmit();
if (form.hasError()) {
return CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
} else {
return CONTINUE_TRAVERSAL;
}
} else {
return CONTINUE_TRAVERSAL;
}
}
}
}
On 7/20/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
i just noticed that we call button.onsubmit() /before/ form.onsubmit(), i always believed this to be the other way around because that is more intuitive - cascading onsubmit down the component hierarchy. is there a reason why we do it "backwards"?
i have also noticed a pattern where i group certain fields in a panel and would like to let the panel also have an onsubmit() for processing. i was thinking of implementing IFormSubmitAware { void onSubmit(); } and bubble this down via a visitor in form.delegatesubmit() but of course with the button getting called first it makes no sense.
shall we reverse it in 2.0? should i put the iformsubmitaware into 2.0 core?
-Igor
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Wicket-develop mailing list Wicket-develop@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-develop