Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7854901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:13:35+00:00 2026-06-02T20:13:35+00:00

I have a Wicket Textfield which contains an Integer value currentValueTextField = new TextField<IntParameter>(valueText,

  • 0

I have a Wicket Textfield which contains an Integer value

currentValueTextField = new TextField<IntParameter>("valueText", new PropertyModel<IntParameter>(model, "value"));

I’m attaching a custom validator to this, as follows

currentValueTextField.add(new IntegerValidator());

The validator class is

class IntegerValidator extends AbstractValidator<IntParameter> {

private static final long serialVersionUID = 5899174401360212883L;

public IntegerValidator() {
}

@Override
public void onValidate(IValidatable<IntParameter> validatable) {
    ValidationError error = new ValidationError();
    if (model.getValue() == null) {
        AttributeAppender redOutline = new AttributeAppender("style", new Model<String>("border-style:solid; border-color:#f86b5c; border-width: 3px"), ";");
        currentValueTextField.add(redOutline);
        currentValueTextField.getParent().getParent().add(redOutline);
        validatable.error(error);
        }
    }
}

However if I type nothing in the textfield, my onValidate() method is not being called.

What is the recommended way to check for null values in this case?
I would also like to do range checking on the value entered.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:13:36+00:00Added an answer on June 2, 2026 at 8:13 pm

    Override validateOnNullValue() that is false by default.

    @Override
    public boolean validateOnNullValue()
    {
         return true;
    }
    

    This is the description of validateOnNullValue() method:

    Indicates whether or not to validate the value if it is null. It is usually desirable to skip validation if the value is null, unless we want to make sure
    the value is in fact null (a rare use case). Validators that extend this and
    wish to ensure the value is null should override this method and return
    true.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a wicket form which contains many TextField input components. There's a Validator
I have a wicket page , which contains two Spring-managed beans , one is
I'm new to wicket and stuck with the following problem: I have a table
I have a Wicket Web Page where I create a new Object of class
I have a wicket application which can be deployed in different environments. One of
i have a web site which is created by wicket(java) but in special cases
In a Wicket app, I have a decimal number text field: TextField<BigDecimal> f =
I have a Wicket AuthenticatedWebApplication which has several pages and features that need to
I have a Wicket page which will dynamically display an image. Let's say the
I have a modal dialog in Wicket that contains a link. I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.