psisoyev
psisoyev

Reputation: 2168

Apache wicket validation

I have custom validation added to my page, and this validation is called from business logic layer, after I click "Save" button on UI, which is AjaxSubmitLink.

On my page I have apache wicket DateTimeField, but it's validation doesn't work correctly: error message doesn't appear in FeedbackPanel, which is added on page and my custom validation is shown there correctly.

So for example I fill hours field with "321" and I will have error in console:

WARN org.apache.wicket.protocol.http.WebSession - Component-targetted feedback message was left unrendered. This could be because you are missing a FeedbackPanel on the page. Message: [FeedbackMessage message = "Translation for key [hours.RangeValidator] is not found for language [en]!", reporter = hours, level = ERROR]

Maybe someone had similar problems and have solution for this?

Thanks!

Upvotes: 0

Views: 1894

Answers (1)

rotsch
rotsch

Reputation: 1929

Because you do an Ajax-Request you have to add the feedback-panel to your AjaxRequestTarget (so it will update itself on every request).

You have to override the onError method though:

add(new AjaxSubmitLink() {
    @Override
        protected void onError(final AjaxRequestTarget target, final Form form) {
        target.addComponent(yourFeedbackPanel);
    }
}

Upvotes: 6

Related Questions