Migrating to Wicket 6.0
Table of Contents | ||
---|---|---|
|
Environment
- Wicket 6.0 requires at least Java 6
...
- `StringValidator` will add the `maxlength` attribute if added to a component attached to an input tag
MinimumValidator
andMaximumValidator
are replaced byRangeValidator.minimum
andRangeValidator.maximum
respectively- `AbstractValidator` has been removed
- `ValidationError` now makes creating standard error keys (classname and classname.subtype) easier. Before one had to do: new ValidationError().addMessageKey(validator.getClass().getSimpleName()) to construct the default key, now you can simply say new ValidationError(validator) and it will do the above for you. Also, for more specific keys one had to do new ValidationError().addMessageKey(validator.getClass().getSimpleName()+".variant"), now you can do new ValidationError(validator, "variant").
Most validators provide a `decorate(ValidationError, Validatable)` method for overriding how they report errors. For example, to add an extra resource key for the error message to StringValidator one can do
Code Block class MyStringValidator extends StringValidator { ValidationError decorate(ValidationError error, IValidatable validatable) { error.addKey("mystringerror"); return error; } }
- org.apache.wicket.validation.RawValidationError is introduced. It can be used to bring a raw Serializable object which is registered as FeedbackMessage with org.apache.wicket.Component#error(Serializable).
- IFormValidator can have its own resource bundle as other IValidator implementations. WICKET-3879
...
o.a.w.ajax.AjaxRequestTarget is an interface now with a default implementation o.a.w.ajax.AjaxRequestHandler. This way it will be possible to replace it with a different implementation, or mock/spy it in tests.
This change required to refactor AjaxRequestTarget.get() too. The replacement code is:
Code Block |
---|
AjaxRequestTarget target = requestCycle.find(AjaxRequestTarget.class);
|
...
IHeaderResponse has been rewritten to render HeaderItems. All render* methods have been replaced by a single render(HeaderItem) method. HeaderItems can be instantiated using the factory methods in JavaScriptHeaderItem, CssHeaderItem, OnDomReadyHeaderItem, OnLoadHeaderItem, OnEventHeaderItem and StringHeaderItem. For example, the following code in renderHead:
Code Block |
---|
response.renderCSSReference(new CssResourceReference(HomePage.class, "header.css"));
response.renderJavaScriptReference(new JavaScriptResourceReference(HomePage.class, "page.js"));
response.renderOnDomReadyJavaScript("foobar");
|
Needs to be replaced with:
Code Block |
---|
response.render(CssHeaderItem.forReference(new CssResourceReference(HomePage.class, "header.css")));
response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(HomePage.class, "page.js")));
response.render(OnDomReadyHeaderItem.forScript("foobar));
|
...
- Files#getLocalFileFromUrl(URL) decodes url before returning file
- WizardStep header labels encode their model values by default, override WizardStep#getHeader() if you need the old behavior (i.e. model values not encoded)
- IErrorMessageSource#substitute(Map<String,Object>) was merged into IErrorMessageSource#getMessage(String, Map<String,Object>)
- org.apache.wicket.util.resource.IResourceStreamWriter#write() now works again with java.io.OutputStream as in Wicket 1.4.x. WICKET-4601
- WicketTester.startPanel -> WicketTester.startComponentInPage
- WebSession#authenticate() was moved to AuthenticatedWebSession and now abstract
- ChoiceFilteredPropertyColumn/ChoiceFilter use DropDownChoice#setNullValid(true) now