...
This is an improvement in Wicket 7.0 which should not affect any application migrating from Wicket 6.x. But if you use Servlet 3.0's AsyncContext in IResource in Wicket 7 then make sure that your code flushes the http response after completing the request.
API changes
...
Changes to org.apache.wicket.
...
ajax.
...
json.* WICKET-6287 - Switch from json.org to open-json RESOLVED
Because of license issues all classes in the mentioned package have been replaced by classes of open-json (https://github.com/tdunning/open-json) which means that the basic functionality is nearly the same. Some classes however (example: org.json.HTTP) are throwing WicketRuntimeExceptions because there is no corresponding implementation in open-json, yet. json.org can be used in this case (can be found in the central maven repository) if the license conditions are accepted.
DecimalConverters' number format WICKET-5853 WICKET-5861
org.apache.wicket.util.convert.converter.AbstractDecimalConverter's #getNumberFormat() and #setNumberFormat() has been removed in favour of #newNumberFormat(). Applications using the old methods should override the new one, where they configure specifics or preserve a reference to the created NumberFormat.
org/apache/wicket/core/util/io/SerializableChecker is replaced with org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream WICKET-4817
CheckingObjectOutputStream accepts a list of org.apache.wicket.core.util.objects.checker.IObjectChecker objects which are used to check for different kind of problems during object serialization. Commit diff: d0441059e0
Use org.apache.wicket.core.util.objects.checker.ObjectSerializationChecker as a replacement.
org/apache/wicket/markup/html/border/BoxBorder is removed with no replacement WICKET-4966.
BoxBorder class has been deprecated in Wicket 6.x series
org.apache.wicket.Component#renderHead(HtmlHeaderContainer) is renamed to Component#internalRenderHead(HtmlHeaderContainer) WICKET-4964
Component#renderHead(HtmlHeaderContainer) was very similar to the usually used Component#renderHead(IHeaderResponse). So it has been renamed to avoid any confusions.
org.apache.wicket.request.resource.ResourceReference#getDependencies() now returns a mutable List<HeaderItem> WICKET-5124
The old API returned Iterable<? extends HeaderItem> and was inconvenient to override and add additional dependencies.
With the new API it is as easy as:
Code Block | ||||
---|---|---|---|---|
| ||||
@Override
public List<HeaderItem> getDependencies() {
List<HeaderItem> dependencies = super.getDependencies();
dependencies.add(dep1);
dependencies.add(dep2);
return dependencies;
}
|
The same is done for org.apache.wicket.markup.head.HeaderItem#getDependencies() too.
org.apache.wicket.model.StringResourceModel interpolation of null in resourceKey WICKET-5820
If a null value is interpolated into the resourceKey, it will now be represented as 'null' instead of the variableName. Thus if you had "weather.${status}=..." in your resource file, you now should use "weather.null=..."
CheckingObjectOutputStream accepts a list of org.apache.wicket.core.util.objects.checker.IObjectChecker objects which are used to check for different kind of problems during object serialization. Commit diff: d0441059e0
Use org.apache.wicket.core.util.objects.checker.ObjectSerializationChecker as a replacement.
org/apache/wicket/markup/html/border/BoxBorder is removed with no replacement WICKET-4966.
BoxBorder class has been deprecated in Wicket 6.x series
org.apache.wicket.Component#renderHead(HtmlHeaderContainer) is renamed to Component#internalRenderHead(HtmlHeaderContainer) WICKET-4964
Component#renderHead(HtmlHeaderContainer) was very similar to the usually used Component#renderHead(IHeaderResponse). So it has been renamed to avoid any confusions.
org.apache.wicket.request.resource.ResourceReference#getDependencies() now returns a mutable List<HeaderItem> WICKET-5124
The old API returned Iterable<? extends HeaderItem> and was inconvenient to override and add additional dependencies.
With the new API it is as easy as:
Code Block | ||||
---|---|---|---|---|
| ||||
@Override
public List<HeaderItem> getDependencies() {
List<HeaderItem> dependencies = super.getDependencies();
dependencies.add(dep1);
dependencies.add(dep2);
return dependencies;
}
|
The same is done for org.apache.wicket.markup.head.HeaderItem#getDependencies() too.
org.apache.wicket.model.StringResourceModel constructor accepts IModel<String> for its default value WICKET-4972
There were two problems with the old way:
- since the parameters argument type is Object..., i.e. varargs, it was hard for the compiler and runtime to differentiate the "defaultValue" from the "parameters"
- it wasn't possible to use lazy evaluation of the default value
If in your application you have code like:
Code Block | ||||
---|---|---|---|---|
| ||||
StringResourceModel model = new StringResourceModel(resourceKey, model, "Some default value", new Object[] [param1, param2]);
|
then the simplest solution is to use Model.of("Some default value"):
Code Block | ||||
---|---|---|---|---|
| ||||
StringResourceModel model = new StringResourceModel(resourceKey, model, Model.of("Some default value"), new Object[] [param1, param2]);
|
org.apache.wicket.extensions.validation.validator.+Xyz+Validator#decorate() now works with IValidationError WICKET-5174
This method now accepts IValidationError as an argument and returns IValidationError. This way it can be used with other IValidationError implementations like RawValidationError for example.
org.apache.wicket.ajax.attributes.AjaxRequestAttributes#setAllowDefault() is deprecated in favour of #setPreventDefault() WICKET-5197
This is done to make it more consistent with JavaScript API.
Same for #isAllowDefault() - use #isPreventDefault() instead.
org.apache.wicket.
...
This is done to make it more consistent with JavaScript API.
org.apache.wicket.ajax.form.AjaxFormValidatingBehavior doesn't use static methods anymore WICKET-5196
To use AjaxFormValidatingBehavior in Wicket 6.x the application code should do something like:
Code Block | ||||
---|---|---|---|---|
| ||||
AjaxFormValidatingBehavior.addToAllFormComponents(form, "keydown", Duration.ONE_SECOND);
|
Due to the usage of static method it wasn't possible to extend this behavior and override for example #updateAjaxAttributes(AjaxRequestAttributes).
The behavior has been reworked a bit to allow this. The new usage is:
Code Block | ||||
---|---|---|---|---|
| ||||
form.add(new AjaxFormValidatingBehavior("keydown", Duration.ONE_SECOND);
|
or
Code Block | ||||
---|---|---|---|---|
| ||||
formComponent.add(new AjaxFormValidatingBehavior("keydown", Duration.ONE_SECOND);
|
in this case the formComponent's owning Form will be used.
org.apache.wicket.ajax.AjaxRequestTarget.IListener#updateAjaxAttributes() is introduced WICKET-5212
...
model.StringResourceModel constructor accepts IModel<String> for its default value WICKET-4972
There were two problems with the old way:
- since the parameters argument type is Object..., i.e. varargs, it was hard for the compiler and runtime to differentiate the "defaultValue" from the "parameters"
- it wasn't possible to use lazy evaluation of the default value
- the amount of parameters for StringResourceModel resulted in rather cryptic code indecipherable for mere mortals.
So we opted to remove most of the constructors of StringResourceModel and use a fluent API instead. For ease of migration you can use the StringResourceModelMigration class to alleviate the pain of figuring out the right way to construct your instance using the new fluent API.
Change the new StringResourceModel(...)
constructor call to an invocation of StringResourceModelMigration.of(...)
, and then perform the Inline Method refactoring of your IDE.
org.apache.wicket.extensions.validation.validator.+Xyz+Validator#decorate() now works with IValidationError WICKET-5174
This method now accepts IValidationError as an argument and returns IValidationError. This way it can be used with other IValidationError implementations like RawValidationError for example.
org.apache.wicket.ajax.
...
attributes.AjaxRequestAttributes#setAllowDefault() is deprecated in favour of #setPreventDefault() WICKET-5197
This is done to make it more consistent with JavaScript API.
Same for #isAllowDefault() - use #isPreventDefault() instead.
org.apache.wicket.ajax.attributes.AjaxRequestAttributes#eventPropagation is now BUBBLE by default WICKET-5198
This is done to make it more consistent with JavaScript API.
org.apache.wicket.ajax.form.AjaxFormValidatingBehavior doesn't use static methods anymore WICKET-5196
To use AjaxFormValidatingBehavior in Wicket 6.x the application code should do something like:
Code Block | ||||
---|---|---|---|---|
| ||||
AjaxFormValidatingBehavior.addToAllFormComponents(form, "keydown", Duration.ONE_SECOND);
|
Due to the usage of static method it wasn't possible to extend this behavior and override for example #updateAjaxAttributes(AjaxRequestAttributes).
The behavior has been reworked a bit to allow this. The new usage is:
Code Block | ||||
---|---|---|---|---|
| ||||
form.add(new AjaxFormValidatingBehavior("keydown", Duration.ONE_SECOND);
|
or
Code Block | ||||
---|---|---|---|---|
| ||||
formComponent.add(new AjaxFormValidatingBehavior("keydown", Duration.ONE_SECOND);
|
in this case the formComponent's owning Form will be used.
org.apache.wicket.ISessionListener#onUnbound(String) is added WICKET-5213
This way all registered ISessionListeners will be notified when a Session is unbound.
(Base)WicketTester uses org.junit.Assert instead of junit.framework.Assert
junit.framework.Assert is deprecated. Due to this change org.junit.Assert#fail() throws now java.lang.AssertionError instead of junit.framework.AseertionFailedError
(Base)WicketTester can be reused after thrown exception
If an exception is thrown during processing in BaseWicketTester or the request was not processed by Wicket, you have to use #getLastRequest() to access this request (was #getRequest() previously).
WICKET-5389.
...
org.apache.wicket.
...
ajax.AjaxRequestTarget.IListener#updateAjaxAttributes() is introduced WICKET-5212
With WICKET-4958 has been introduced orgtester.WicketTester#assertErrorMessages and org.apache.wicket.utilajax.tester.WicketTester#assertInfoMessages now accept a list/varargs of java.io.Serializable as argument, instead of list of Strings.
This makes these methods consistent with org.apache.wicket.Component#error and other feedback message related methods.
Whatever type of message you pass to Component#error() the same message type can be asserted onAjaxRequestTarget.AbstractListener which is an empty implementation of AjaxRequestTarget.IListener to be able to introduce AbstractListener#updateAjaxAttributes() method - a place where an application can configure globally the Ajax attributes. With WICKET-5212 this new method is moved to the interface as well.
From now on it is recommended all implementations of AjaxRequestTarget.IListener to extend from AjaxRequestTarget.AbstractListener. This way they won't need to a implement another method when a new one is added in a major release.
org.apache.wicket.
...
ISessionListener#onUnbound(
...
String) is added WICKET-5213
This way all registered ISessionListeners will be notified when a Session is unbound.
(Base)WicketTester uses org.junit.Assert instead of junit.framework.Assert
junit.framework.Assert is deprecated. Due to this change org.junit.Assert#fail() throws now java.lang.AssertionError instead of junit.framework.AseertionFailedError
(Base)WicketTester can be reused after thrown exception
If an exception is thrown during processing in BaseWicketTester or the request was not processed by Wicket, you have to use #getLastRequest() to access this request (was #getRequest() previously).
WICKET-5389.
WicketTester assert feedback message methods work with java.io.Serializable WICKET-5128
Component and Session's meta data must be serializable.
org.apache.wicket.Application#getHeaderContributorListenerCollection() is renamed to #getHeaderContributorListeners()
This way it is consistent with the other #getXyzListeners() methods in Application class
org.apache.wicket.authorization.IAuthorizationStrategy#isResourceAuthorized(IResource, PageParameters) is introduced WICKET-5012
Wicket 7.x supports authorization for requests to resources (IResource) additionally to authorization for components.
...
org.apache.wicket.
...
util.
...
tester.WicketTester#assertErrorMessages and org.apache.wicket.
...
orgutil.apache.wicket.Component#setResponsePage(page) just delegates to tester.WicketTester#assertInfoMessages now accept a list/varargs of java.io.Serializable as argument, instead of list of Strings.
This makes these methods consistent with org.apache.wicket.Component#error and other feedback message related methods.
Whatever type of message you pass to Component#error() the same message type can be asserted on.
org.apache.wicket.
...
Component#setMetaData() value could be only a Serializable WICKET-5227
Component and Session's meta data must be serializable
AutoCompleteTextField doesn't support useHideShowCoveredIEFix setting WICKET-5130
useHideShowCoveredIEFix setting was needed for IE7 support. This version of IE is not supported officially anymore and this setting has been removed.
org.apache.wicket.
...
Application#getHeaderContributorListenerCollection() is renamed to #getHeaderContributorListeners()
This way it is consistent with the other #getXyzListeners() methods in Application class
org.apache.wicket.authorization.IAuthorizationStrategy#isResourceAuthorized(IResource, PageParameters) is introduced WICKET-5012
Wicket 7.x supports authorization for requests to resources (IResource) additionally to authorization for components.
org.apache.wicket.Component#setResponsePage() now accepts org.apache.wicket.request.component.IRequestablePage instead of org.apache.wicket.Page
org.apache.wicket.Component#setResponsePage(page) just delegates to org.apache.wicket.request.cycle.RequestCycle#setResponsePage() that required just IRequestablePage.
AutoCompleteTextField doesn't support useHideShowCoveredIEFix setting WICKET-5130
useHideShowCoveredIEFix setting was needed for IE7 support. This version of IE is not supported officially anymore and this setting has been removed
org.apache.wicket.extensions.markup.html.form.DateTextField can be used with several date-like types: date, datetime, datetime-local, month, time, week.
To be able to support this the return type of TextField#getInputType() has been changed from String to String[], and the method itself has been renamed to #getInputTypes().
To migrate it you should do something like:
Code Block | ||||
---|---|---|---|---|
| ||||
...
@Override
protected String getInputType()
{
return "sometype";
}
...
|
to
Code Block | ||||
---|---|---|---|---|
| ||||
...
@Override
protected String[] getInputTypes()
{
return new String[] { "sometype" };
}
...
|
AuthenticatedWebSession#authenticate is now protected instead of public. WICKET-5308
No change in user code is required, but the authenticate method can now be made protected to avoid confusion with the signIn method.
AbstractResource.ResourceResponse API became more fluent. WICKET-5330
All setter methods in AbstractResource.ResourceResponse class now will return this instance for method chaining.
org.apache.wicket.markup.
...
html.form.TextField#getInputType() returns String array WICKET-5286
org.apache.wicket.extensions.markup.html.form.DateTextField can be used with several date-like types: date, datetime, datetime-local, month, time, week.
To be able to support this the return type of TextField#getInputType() has been changed from String to String[], and the method itself has been renamed to #getInputTypes().
To migrate it you should do something like:
Code Block | ||||
---|---|---|---|---|
| ||||
...
@Override
protected String getInputType()
{
return "sometype";
}
...
|
to
Code Block | ||||
---|---|---|---|---|
| ||||
...
@Override
protected String[] getInputTypes()
{
return new String[] { "sometype" };
}
...
|
AuthenticatedWebSession#authenticate is now protected instead of public. WICKET-5308
No change in user code is required, but the authenticate method can now be made protected to avoid confusion with the signIn method.
AbstractResource.ResourceResponse API became more fluent. WICKET-5330
All setter methods in AbstractResource.ResourceResponse class now will return this instance for method chaining.
org.apache.wicket.markup.head.IHeaderItemWrapper is merged to IWrappedHeaderItem. WICKET-5366
IHeaderItemWrapper was a temporary class used to add a new method (#wrap(HeaderItem)) without breaking the APIs in Wicket 6.x.
The new method is moved its proper class - IWrappedHeaderItem.
All 'QuirkXyz' properties has been removed from org.apache.wicket.protocol.http.ClientProperties WICKET-5370
The 'quirk' properties were mostly related to IE6/7 and old versions of Firefox browsers.
org.apache.wicket.request.resource.AbstractResource#flushResponseAfterHeaders() is removed WICKET-
IHeaderItemWrapper was a temporary class used to add a new method (#wrap(HeaderItem)) without breaking the APIs in Wicket 6.x.
The new method is moved its proper class - IWrappedHeaderItem.
All 'QuirkXyz' properties has been removed from org.apache.wicket.protocol.http.ClientProperties WICKET-5370
The 'quirk' properties were mostly related to IE6/7 and old versions of Firefox browsers.
org.apache.wicket.request.resource.AbstractResource#flushResponseAfterHeaders() is removed WICKET-5392
This method was needed as a workaround for some old version of Firefox that had an issue with rendering images.The flush of the headers caused problems with proper buffering of the response, e.g. when the response needs to be compressed.
...
The pattern is used to check whether a candidate String could be a version.
To allow any pattern this method can return null or Pattern.compile(".*" )
remove org.apache.wicket.markup.html.form.IChoiceRenderer interface WICKET-663
With WICKET-663 we wanted to add a new method to the interface that will allow faster lookup of an object by its id.
It wasn't easy to add this new method because it would break the API.
Since the creation of WICKET-663 until now there was no big benefit of having the interface so we decided to drop it.
a version.
To allow any pattern this method can return null or Pattern.compile(".*" )
add org.apache.wicket.markup.html.form.IChoiceRenderer#getObject(String idValue, IModel<? extends List<? extends T>> choices) method WICKET-663
This method should return the object that produces idValue when org.apache.wicket.markup.html.form.IChoiceRenderer#getIdValue(T object, int index) is calledAny custom implementations of IChoiceRenderer interface now should extend from ChoiceRenderer class.
remove org.apache.wicket.request.mapper.mount.MountMapper WICKET-4686
...
Note: MountMapper and its related classes are still available in 7.x but deprecated and not used by Wicket itself. They will be completely removed in Wicket 8.0.0.0.0
Renamed all *AjaxResponse classes to *PartialPageUpdate WICKET-5929
XmlAjaxResponse was renamed to XmlPartialPageUpdate (see git commit 7c40e4dafa75973bf99b34567d977f310a5f02d0)
AuthenticatedWebApplication#onUnauthorizedPage WICKET-5490
...
Components' methods and constructors which use collections have been updated to follow best practices. List of updated components:
AbstractChoice, CheckGroup, FileUploadField, ListView, PageableListView, PropertyListView, AbstractPageableView, RefreshingView, ListDataProvider, AjaxEditableChoiceLabel, Palette, SelectOption, SelectOptions, ChoiceFilter, ChoiceFilteredPropertyColumn
Make FormComponent#convertInput() public WICKET-5708
...
Model#of(Collection), Model#ofList(List) and Model#ofSet(Set) have been adjusted to return collections without wildcards.
Make FormComponent#convertInput() public WICKET-5708
The visibility of org.apache.wicket.markup.html.form.FormComponent#convertInput() method has been changed from <em>protected</em> to <em>public</em> to allow application components and behaviors to convert the input of another form component(s) during custom form (component) submit processing.
Use commons-fileupload as Maven dependency instead of keeping copies of its classes WICKET-5503
All classes from package org.apache.wicket.util.upload.** are now in org.apache.commons.fileupload.**.
For example FileItem and FileUploadException.
Rename PageSettings#recreateMountedPagesAfterExpiry to #recreateBookmarkablePagesAfterExpiry WICKET-5829
Rename IStaticCacheableResource#getCacheableResourceStream() to #getResourceStream() WICKET-5909
Behavior changes
org.apache.wicket.request.Url#getQueryString WICKET-4664
...
Check and Radio no longer generade a CSS class attribute, encoding their group's markup id. Wicket no longer needs this - if you do, you can easily write a suitable attribute value by yourselfgroup's markup id. Wicket no longer needs this - if you do, you can easily write a suitable attribute value by yourself.
FileParts must be parsed explicitly before trying to read them WICKET-5839
If a MultipartWebRequest is created manually then FileParts must be parsed explicitly with #parseFileParts(). See http://wicketinaction.com/2012/11/uploading-files-to-wicket-iresource/ for example.
Deprecated classes/methods/fields are removed WICKET-5201
...
All libraries on which Wicket modules depend are updated to their latest stable versions.
The most notable ones are:
- Spring Framework 3.2.24.1.x
- Guice 4.0
- ASM 5.xASM 4.1
- CGLIB 3.01
- SLF4J 1.7.5x
- Jetty (in the quickstart) 89.12.10x