You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 29 Next »

 

Environment

Wicket 8.0 requires at least Java 8

Wicket 8.0 requires Servlet 3.1

API changes

Deprecate org.apache.wicket.util.IProvider  Unable to render Jira issues macro, execution error.

Replace it with standard Java 8 java.util.function.Supplier<T> which is virtually identical.

Deprecate org.apache.wicket.util.IContextProvider  Unable to render Jira issues macro, execution error.

Replace IContextProvider<T, C> with standard Java 8 java.util.function.Function<C, T> which is virtually identical.

As a consequence IPageManagerProvider, IPageRendererProvider and IRequestCycleProvider now override #apply() method instead of #get().

Deprecate org.apache.wicket.protocol.http.documentvalidation.HtmlDocumentValidator  Unable to render Jira issues macro, execution error.

Tests based on HtmlDocumentValidator are very fragile. They start to fail as soon as there is a single character change somewhere in the page markup.

We believe that there are very few users of this API. It is recommended to use TagTester and WicketTestCase#executeTest() instead.

IGenericComponent's setter methods now return the current instance for method chaining

All specialization classes return their type.

AjaxFallback** components now use java.util.Optional   Unable to render Jira issues macro, execution error.

All AjaxFallback** components and the containers which use internally AjaxFallback** components, like AjaxTabbedPanel, RatingPanel and TableTree, have been reworked to pass Optional<AjaxRequestTarget> instead of just AjaxRequestTarget to their onXyz() callback methods. This way the application developer should not forget to check that the AjaxRequestTarget is not null. 

Behavior changes

FormComponentPanel delegates the call to #clearInput to its FormComponent children  Unable to render Jira issues macro, execution error.

FormComponent#clearInput() has been made non-final, so that now containers like FormComponentPanel could override this method and call #clearInput() on its children of type FormComponent.

Removals

Drop Jetty 7.x and 9.0.x modules for Wicket Native WebSocket  Unable to render Jira issues macro, execution error.

Since Wicket 8.x requires Servlet 3.1 the modules for native websocket support for Jetty 7.x/9.0.x have been dropped.

Users are advised to use wicket-native-websocket-javax module with Jetty 9.2+, Apache Tomcat 7/8, JBoss WildFly.

Improvements

IModel uses Java 8 default interface method for IDetachable#detach()   Unable to render Jira issues macro, execution error.

For convenience IModel class provides a do-nothing implementation of IDetachable#detach() method, so custom implementations are not required to implement it when not needed.

ResourceStreamResource now receives Attributes as a parameter to its #getResourceStream() method  Unable to render Jira issues macro, execution error.

For access to the response, the request and its parameters now ResourceStreamResource#getResourceStream() receives an instance of org.apache.wicket.request.resource.IResource.Attributes.

 

Provide serializable versions of java.util.function.(Supplier|Consumer|Function)  Unable to render Jira issues macro, execution error.

java.util.function.Consumer and other classes are not serializable and this makes them unusable in stateful Wicket pages. For this reason Wicket provides org.apache.wicket.model.lambda.WicketSupplier, org.apache.wicket.model.lambda.WicketConsumer and org.apache.wicket.model.lambda.WicketFunction. Those interfaces should be used in method signatures where Java 8 lambdas or method references could be used. At the call site there is nothing specific to be done, i.e. just use lambdas and method references without any casting.

 

Provide IModel implementations which make use of Java 8 lambdas and method references  Unable to render Jira issues macro, execution error.

Wicket provides three new implementations of IModel which use Java 8 consumers and suppliers, i.e. may be used with lambda or method references

  • org.apache.wicket.model.lambda.LambdaModel.

    LambdaModel
    Person person = ...;
    IModel<String> personNameModel = new LambdaModel<>(
          () -> person.getName(),
          (name) -> person.setName(name));
  • org.apache.wicket.model.lambda.SupplierCachingModel. It is similar to org.apache.wicket.model.LoadableDetachableModel 

    SupplierCachingModel
    Person person = ...;
    IModel<String> personNameModel = new SupplierCachingModel<>(person::getName);

IGenericComponent is a mixin/trait interface  Unable to render Jira issues macro, execution error.

IGenericComponent uses Java 8 default methods to implement #setModel(IModel<T>), #getModel(), #setModelObject(T) and #getModelObject() by delegating to the respective get/setDefaultModel[Object] methods.

This way it could be easily used by any Component by just implementing it.

IModel is a @FunctionalInterface now

IModel provides default implementations of #detach() (do nothing) and #setObject(T) (throws UnsupportedOperationException), so it is possible to use it as a functional interface.

IModel as functional interface
new Link<String>("", () -> "abc") {
   @Override
   public void onClick()
   {
     // ...
   }
};
 
Label label = new Label("id", person::getName); // the method reference is actually IModel<String>

 

Dependency updates

All libraries on which Wicket modules depend are updated to their latest stable versions.
The most notable ones are:

  • Spring Framework 4.2.x
  • Jetty 9.3.x (used in the Quickstart application archetype and for internal Wicket testing)
  • No labels