Form<Void> form = new Form<Void>("form"); form.add(new RequiredTextField<String>("filed")); final TextField<String> textField; form.add(textField = new TextField<String>("filed2", new Model<String>())); form.add(new AjaxButton("button") { @Override protected void onSubmit(AjaxRequestTarget target, @SuppressWarnings("hiding") Form<?> form) { System.out.println("Test." + textField.getConvertedInput()); System.out.println("Test." + textField.getModelObject()); } });
In case if "filed" is empty than onSubmit() method does not call after submitting button. I can find only one solution - to override process() and onValidate() methods of form as fallows: Form<Void> form = new Form<Void>("form") { @Override public void process(IFormSubmittingComponent submittingComponent) { if ("button".equals(submittingComponent.getInputName())) { getApplication().getSessionStore().setAttribute(getRequest(), "button", true); } super.process(submittingComponent); } @SuppressWarnings("unchecked") @Override protected void onValidate() { if (getApplication().getSessionStore().getAttribute(getRequest(), "unvalidate") != null && (Boolean) getApplication().getSessionStore().getAttribute(getRequest(), "unvalidate")) { getApplication().getSessionStore().removeAttribute(getRequest(), "button"); Session.get().getFeedbackMessages().clear(); return; } } }; ...but IMHO it's not good:) What is the correct way to solve this problem? thanks in advance -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-Button-does-not-submit-form-if-RequiredTextField-is-empty-tp2259981p2259981.html Sent from the Wicket - User 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