I am using my own validation, but the view of the form (e.g. if a component is invalid) should be highlighted or customized within wicket…
So e.g.
I have my Wicket Form
<form wicket:id="inputForm">
<p>
<label for="Recipient">Recipient</label>
<input wicket:id="Recipient" id="Recipient" type="text" size="40"/>
</p>
<p>
<label for="Details">Details</label>
<input wicket:id="Details" id="Details" type="text" size="40"/>
</p>
</form>
Then I have my Form.java: Here I set the values of my Java Object “Invoice” and use onValidateModelObjects to override the wicket validation and use my own validation…
This method just calls a simple own created ValidatorObject that takes care of the validation…
public InvoiceForm() {
...
Form<Invoice> form = new Form("inputForm", formModel) {
/*
* Validation takes place here
*/
@Override
public void onValidateModelObjects() {
ValidationProcess vp = new ValidationProcess();
vp.validate("Rules.js", r);
msg = "";
if (vp.getConstraintViolations().size() > 0) {
for (String s : vp.getConstraintViolations()) {
msg = msg + s;
}
} else {
msg = "no errors.";
}
}
};
//adding Textfields to the Form etc...
...
}
What I need: Above you can see that my errorMessages will be saved into the msg String! Now what I want is Wicket to take this String and apply it to the Wicket FeedBackMessage System or however…
- I need to get the component that will be rendered at the moment…
- I have to set the error Message of this component to my component…
how can I do that?
I guess I need to override some methods, but I dont know which ones and where…
I got it working with the following Code: