As I understand the only way to catch the form's onSubmit is by analyze form
components validation which is performed by form submitting. And if
validation is successful then form submit will be done for sure. Am I
correct understand?
Trying to find workaround for this issue,in MyCustomBehavior I found form's
button and added AjaxEvenBehavior("onclick") to it. Strangely but
form.getDefaultButton() returned null and the only way to get form's Button
component is the traversing over all the form components and finding a
button component (not sure if it best way). So when I clicked the button the
AjaxEventBehavior.onEvent occurs (in MyCustomBehavior) and next
AjaxFallbackButton.onSubmit on main form had invoked. But I found that the
target parameter is null in main onSubmit handler of form's
AjaxFallbackButton. What wrong in this case? Why the target is null in
form's buton handler and not null in the form Behavior's button handler.
This is the same button in fact. In the form it have onSubmit handler, and
in MyCustomBehavior it have onEvent handler. A piece of code is given
below...
Thanks a lot for help.
public class MyCustomBehavior extends AbstractBehavior {
......
@Override
public void onConfigure(Component component) {
// this.form.getDefaultButton() - return null in fact (why)
Iterator<? extends Component> iter = form.iterator();
while (iter.hasNext()) {
FormComponent<?> fc = (FormComponent<?>)iter.next();
if (fc.isEnabled() && (fc instanceof Button)) {
fc.add(new AjaxEventBehavior("onclick") {
private static final long
serialVersionUID = 1L;
@Override
protected void
onEvent(AjaxRequestTarget target) {
// here target is not null
System.out.println("clicked
!!!!");
}
});
};
} // end of while
} // end of onConfigure
....
}
// Main page
....
form.add(new AjaxFallbackButton("submit",form) {
protected void onSubmit(AjaxRequestTarget target, Form<?>
aForm) {
// here target is null (why?)
.....
// some main actions for form submit...
}
});
.....
form.add(new MyCustomBehavior(feedback));
.......
// End of main page
-----
Best wishes,
Alex.
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Several-Form-onSubmit-is-it-possible-add-via-AbstractBehavior-tp4656347p4656393.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]