AJAX Button does not submit form if RequiredTextField is empty
FormVoid form = new FormVoid(form); form.add(new RequiredTextFieldString(filed)); final TextFieldString textField; form.add(textField = new TextFieldString(filed2, new ModelString())); 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: FormVoid form = new FormVoid(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
RE: AJAX Button does not submit form if RequiredTextField is empty
http://wicket.apache.org/docs/1.4/org/apache/wicket/markup/html/form/Form.html -Ursprüngliche Nachricht- Von: vov [mailto:vov...@mail.ru] Gesendet: Freitag, 18. Juni 2010 12:11 An: users@wicket.apache.org Betreff: AJAX Button does not submit form if RequiredTextField is empty FormVoid form = new FormVoid(form); form.add(new RequiredTextFieldString(filed)); final TextFieldString textField; form.add(textField = new TextFieldString(filed2, new ModelString())); 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: FormVoid form = new FormVoid(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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: AJAX Button does not submit form if RequiredTextField is empty
Thanks for replay Stefan. Nestet form is a good idea for my example. But am so sorry that simplified it. In some cases there is not easy to make markup using this way. For example I want to use in my onSubmit method model value from 2 or 3 different TextFields or other FormComponents. And all of them are placed in different part of form. I found another answer on my question, but may be any standard solution exists: form.add(new AjaxButton(button) { @Override protected void onSubmit(AjaxRequestTarget target, @SuppressWarnings(hiding) Form? form) { textField.convertInput(); textField.updateModel(); System.out.println(Test. + textField.getConvertedInput()); System.out.println(Test. + textField.getModelObject()); } }.setDefaultFormProcessing(false)); I set defaultFormProcessing to false and manually update neccessary component. But now I need create custom TextField... class MyTextFieldT extends TextFieldT { public MyTextField(String id) { super(id); } @Override public void convertInput() { super.convertInput(); } } ...that make convertInput() method public -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-Button-does-not-submit-form-if-RequiredTextField-is-empty-tp2259981p2260054.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