...
Form component level validation has been decoupled from FormComponent so that validators can be reused outside wicket. The new API can be found in wicket.validation
package, with the validator implementations in wicket.validation.validator
. From the point of view of validator development not much has changed if you extended the AbstractValidator
; if you however implemented the IValidator
interface directly you will need to use the new API, namely error reporting via ValidationError
instead of FormComponent.error(List,Map)
. Errors with messages fully constructed inside the validator can still be reported using FormComponent.error(String)
.
Annotations
Wicket has replaced the need to override certain callback methods with annotation-driven approach.
For an outline of advantages see here https://issues.apache.org/jira/browse/WICKET-23
See
- @OnAttach
- @OnDetach
- @OnBeforeRender
- @OnAfterRender
Code example:
Code Block |
---|
class MyComponent extends WebMarkupContainer {
public void onAttach() {
super.onAttach();
// handle attach event
createRepeaterItems();
createHeaderItems();
}
private void createRepeaterItems() {
...
}
private void createHeaderItems() {
...
}
}
|
becomes
Code Block |
---|
class MyComponent extends WebMarkupContainer {
@OnAttach
private void createRepeaterItems() {
...
}
@OnAttach
private void createHeaderItems() {
...
}
}
|
XML resource bundles
In addition to the .properties format for localized messages, Wicket now supports Java 5's XML format for messages. Like with normal messages, you can just put them next to your component class with the proper locale in the name etc. For instance: MyPanel_nl.xml would be the Dutch language bundle next to MyPanel.class. The format is described here http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html and here http://www-128.ibm.com/developerworks/java/library/j-tiger02254.html?ca=dgr-SEOn-JDK_5.0-XML. The greatest advantage is that you can declare which encoding should be used, thus enabling you to directly maintain your bundles for non-ASCII sets (with normal properties, you have to use escape codes for non-ASCII characters).
...