As per the JavaDocs: http://ci.apache.org/projects/wicket/apidocs/1.5.x/org/apache/wicket/ajax/markup/html/form/AjaxFallbackButton.html#onSubmit(org.apache.wicket.ajax.AjaxRequestTarget, org.apache.wicket.markup.html.form.Form) Callback for the onClick event. If ajax failed and this event was generated via a normal submission, the target argument will be null
*Parameters:*target - ajax target if this linked was invoked using ajax, null otherwise I belive your target is null because you are using a fallback button and you might have JavaScript turned off in your browser? ~ Thank you, Paul Bors On Fri, Feb 15, 2013 at 5:42 AM, Alex <avat...@yahoo.com> wrote: > 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: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >