Reputation: 1
on the database I have a field "Interval" which stores a duration of days and hours in type Long. On the frontend this field is split into two fields. One is "Days" and the other is "Hours" so the users can easily put a duration. I am now trying to validate the input by using a RangeValidator but on submitting the form with a changed value in field days I always get the following exception:
Last cause: null
WicketMessage: Exception 'null' occurred during validation org.apache.wicket.validation.validator.RangeValidator on component 2:tabs:panel:form:days
HTML
<form wicket:id="form">
<input wicket:id="days" type="text">
<input wicket:id="submit" type="submit" value="Update">
</form>
Java
public IntervalPanel(String id, IModel<Experiment> experimentModel) {
super(id, experimentModel);
form = createForm();
add(form);
}
private Form createForm() {
Experiment experiment = getModel().getObject();
long interval = experiment.getInterval();
TextField days = new TextField("days", new Model<>(interval / 24L));
RangeValidator rangeValidator = new RangeValidator(Long.MIN_VALUE, Long.MAX_VALUE);
days.add(rangeValidator);
Form form = new Form<>("form").add(days);
return form;
}
Since I am just starting to work with Wicket this may be just an understanding problem of how to use the RangeValidator and I hope you can help me figuring out how to get the validator to work.
Regards
Upvotes: 0
Views: 592
Reputation: 1
Thanks for the quick replys to my question. In addition to this post I asked a friend of mine if he could help me on this and he figured that it gives me null because the value of the field is not stored on the db. So this has been a rookie mistake, but thanks anyways :)
Upvotes: 0