laurt
laurt

Reputation: 1881

Changing Wicket text field validation error message

I have a text field that uses a PropertyModel, like this:

TextField<Integer> ageField = new TextField<Integer>("age", 
                      new PropertyModel<Integer>(person, "age"));

When a non-integer value is submitted, the following error is displayed in the browser:

"The value of 'age' is not a valid Integer."

How can I modify this error message?

Upvotes: 2

Views: 5160

Answers (4)

Melissa Beldman
Melissa Beldman

Reputation: 21

Add age.IConverter.Integer = Your Custom Message to your properties file

Upvotes: 2

Imperative
Imperative

Reputation: 3183

In Wicket 6 you need to set up a properties file with the inputs Wicket-ID appended by .Required:

myinput.Required = Please provide this input field

Define own feedback messages in Wicket

Upvotes: 5

laurt
laurt

Reputation: 1881

What worked for me was adding this to the properties file:

<entry key="IConverter.Integer">${label} must be an integer.</entry>

Upvotes: 1

Martin
Martin

Reputation: 1273

Create a properties file and specify your own message:

TextField.age=Your custom message

More info about properties here and here

Upvotes: 3

Related Questions