Hi, Your validator needs to implement org.apache.wicket.markup.html.form.validation.IFormValidator to be able to validate on form level.
On Mon, Dec 3, 2012 at 11:04 PM, ttboy_01 <[email protected]> wrote: > Hi community, > > I've got a little problem here with a real simple form. Everything is > working fine except the validation of my Validator which is never called. > I've set a breakpoint to the "onvalidation" method... nothing. I think I am > missunderstanding the architecture of form/validation. > > Here's the sample code: > > ************************** > *** Page > ************************** > > public class MyTestPage extends HomePage { > > /** > * > */ > private static final long serialVersionUID = 6374488865423191635L; > > private IModel<Article> article = Model.of(new Article()); > > public MyTestPage() { > this(null); > } > > public MyTestPage(PageParameters params) { > super(params); > > add(new FeedbackPanel("testPage.feedback", new > ComponentFeedbackMessageFilter(this))); > > add(new MyTestForm("testPage.myForm", article)); > } > > class MyTestForm extends Form<Article> { > > /** > * > */ > private static final long serialVersionUID = > -1961809427855436256L; > > public MyTestForm(String id, IModel<Article> model) { > super(id, new > CompoundPropertyModel<Article>(model)); > > TextField<String> myText = new > TextField<String>("testPage.myText", new > PropertyModel<String>(getModel(), "EAN")); > add(myText); > DropDownChoice<ArticleStatus> myDropDown = new > DropDownChoice<ArticleStatus>("testPage.myDropDown", new > PropertyModel<ArticleStatus>(getModel(), "status"), > > Arrays.asList(ArticleStatus.values())); > add(myDropDown); > > AjaxButton btSave = new > AjaxButton("testPage.save", MyTestForm.this) { > > @Override > protected void onSubmit(AjaxRequestTarget > target, Form<?> form) { > > Article article = ((Article) > getParent().getDefaultModelObject()); > // save article -> working > > } > > @Override > protected void onError(AjaxRequestTarget > target, Form<?> form) { > // add feedback panel here -> but > this is never called > } > }; > add(btSave); > > Button btCancel = new Button("testPage.cancel") { > > @Override > public void onSubmit() { > setResponsePage(HomePage.class); > } > > }; > btCancel.setDefaultFormProcessing(false); > add(btCancel); > > add(new ArticleValidator(myDropDown, myText)); > } > } > > } > > ************************** > *** Validator > ************************** > public class ArticleValidator extends AbstractValidator<Article> implements > IValidator<Article> { > > //... > } > > Thanks for help. > Regards, > Erik > > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/Form-Validation-not-called-tp4654443.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] > > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com <http://jweekend.com/>
