Wicket - IValidator not calling validate when TextField is empty

I have a class that implements the IValidator. I add this validator class to my TextField, and the overrided method validate(Invalidatable<T>) is called. However, if the TextFieldis empty, the method is not called, and the validation does not occurs. Why is this happening? Is this expected behavior?

Validator Class

public class CorporateNameValidator implements IValidator<String> {

        private static final String ERROR_EMPTY = "Error";

        public void validate(IValidatable<String> validatable) {

            //Method not called when TextField has blank value.

            final String name = validatable.getValue();

            info("NAME: " + name);

Instantiating TextField

corporateNameInput = new TextField<String>(CORPORATE_NAME_INPUT_ID, new PropertyModel<String>(this, ""));

Setting TextField Properties

corporateNameInput.add(new CorporateNameValidator()); corporateNameInput.setOutputMarkupPlaceholderTag(true);

And then I add the TextField to the Form.


From the JavaDoc of IValidator:

Interface representing a validator that can validate an IValidatable object.

Unless the validator implements the INullAcceptingValidator interface as well, Wicket will not pass null values to the IValidator#validate(IValidatable) method.

It is as designed, and you should implement INullAcceptingValidator instead.

Need Your Help

Combining Two Jquery Plug-ins: Not Working

jquery html jquery-ui

Okay, so I have been trying to combine the CarouFredSel and jquery custom content scroller to add an image of a scroll bar that works with the carousel. I am pretty sure that I am doing something w...

Android: Open PDF File from the start every time

android android-intent android-button

I have a button in my app that opens a pdf file when you press it. However when I exit the pdf file and then press the button again it opens the pdf file at the page I was last on.Is it possible to...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.