I find it logical that it did go last, It is the Top thing. First all the children then the parent. (i do find that logical somehow)
But i don't think it matters to much. Because most have the form.submit OR a button.submit() implemented.
But what is your usecase exactly? What do you want? Or better said what do you need. Do you need a callback
to a component when everything is validated correctly but before the submit? What do you want to do in that method?
johan
On 7/21/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
then of course then there is the semantic of when onvalidate() is called - only if validators+form validators are all valid, or always, i dont have a strong preference.
-IgorOn 7/20/06, Igor Vaynberg <[EMAIL PROTECTED] > wrote:or alternatively we defined another onValidate() callback that is called as part of validation so users can hook into it.
we always tell our users to use onsubmit() for form level validation - but of course this wont work right if the button's onsubmit is called before the forms!
so we can additionally have IFormValidationAware { void onValidate(); } and form.onValidate();
right now users can override form.validate(), but then they must remember to call super() before they do any processing. dont know if thats the way we want to go as it might be error prone.
-IgorOn 7/20/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:so something like this:
@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
------------------------------------------------------------------------- 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