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

Compare with Current View Page History

« Previous Version 58 Next »

 

Environment

Wicket 8.0 requires at least Java 8

Wicket 8.0 requires Servlet 3.1 (Jetty 9.2+, Apache Tomcat 8+, JBoss WildFly 10+)

API changes

Changes to org.apache.wicket.ajax.json.*  Unable to render Jira issues macro, execution error.

Because of license issues all json.org classes in that package have been removed and open-json (https://github.com/tdunning/open-json) is used as new dependency. Basic functionalities can be reused by only changing the imports from org.apache.wicket.ajax.json.* to org.json.*, org.apache.wicket.ajax.json.JsonFunction has been renamed to org.apache.wicket.ajax.json.JSONFunction and some classes are deleted without any replacements (example: org.json.HTTP)

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.

Deprecate org.apache.wicket.model.AbstractReadOnlyModel

Use an anonymous instance of IModel instead. Since Wicket 8.0 IModel doesn't require providing implementation of #setObject(Object) method.

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

All specialization classes return their type.

AjaxButton, AjaxLink and AjaxFallbackButton event callback methods no longer get form as second argument  Unable to render Jira issues macro, execution error.
 

For consistency with other components and the new lambda support, the submitted form is no longer passed as argument to callback methods (e.g. #onSubmit(), #onClick()) of AjaxButton, AjaxLink and AjaxFallbackButton. You can call #getForm() instead.

 

RequestCycle#find(Class<T>) returns java.util.Optional  Unable to render Jira issues macro, execution error.

 

Code calling RequestCycle#find(Class<T>) has to check whether  a matching IRequestHandler is found. This is now enforced by returning an Optional<T>:

RequestCycle.find(Class<T>)
getComponent().getRequestCycle().find(AjaxRequestTarget.class).ifPresent(target -> target.add(this)); 

Silent API break

During migration you should check your old code for places where the AjaxRequestCycle (now an Optional<AjaxRequestTarget>) is compared with null:

Pitfall when comparing with null
if (cycle.find(AjaxRequestTarget.class) == null) {
  // this is *never* executed since #find() always returns an Optional
}

if (cycle.find(AjaxRequestTarget.class) != null) {
  // this is *always* executed since #find() always returns an Optional
}

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. 

AbstractChoice#getChoices() is 'final' now   Unable to render Jira issues macro, execution error.

AbstractChoice#getChoices() has been made final. If the application needs to provide different choices for each render then it should override AbstractChoice#getChoicesModel() instead. The application code would be almost the same as before, it will just need to wrap the final List result in an IModel, most probably ListModel.

ListenerInterfaceRequestHandler simplification Unable to render Jira issues macro, execution error.

RequestListenerInterface was removed:

  • IResourceListener, IBehaviorListener, IOnChangeListener, ILinkListener are replaced by the generic method IRequestListener#onRequest()
  • ListenerInterfaceRequestHandler was renamed to ListenerRequestHandler
  • Component's and Behavior's #canCallListenerInterface() were renamed to #canCallListener()
  • PageSettings#getCallListenerInterfaceAfterExpiry() was renamed to #getCallListenerAfterExpiry.

A Component or Behavior can now implement IRequestListener once only, thus removing the need to include an identifier (e.g. "ILinkListener") in the URL.

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.

Use DynamicJQueryResourceReference by default  Unable to render Jira issues macro, execution error.

By using org.apache.wicket.resource.DynamicJQueryResourceReference Wicket will contribute jQuery ver. 2.x for modern browsers and ver. 1.x when the request is done by Internet Explorer older than ver. 9.

AuthenticatedWebSession#singOut() now is an alias of Session#invalidate()  Unable to render Jira issues macro, execution error.

The old behavior of #signOut() didn't bring much value and caused confusion to some users. Now it is just an alias of Session#invalidate().

SecuritySettings#enforceMounts(true) now disables BookmarkableMapper   Unable to render Jira issues macro, execution error.

If this setting is enabled then a page could not be requested via /wicket/bookmarkable/com.example.PageName. A page has to be explicitly mounted at MyApplication#init() to be able to request it.

Removals

Drop Tomcat 7.x, Jetty 7.x and Jetty 9.0.x modules for Wicket Native WebSocket  Unable to render Jira issues macro, execution error.   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.

Drop Atmosphere module  Unable to render Jira issues macro, execution error.

The experimental integration for Atmosphere has been removed because of stability issues.

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

Remove deprecated classes Unable to render Jira issues macro, execution error.

Several deprecated classes where removed:

  • IMountedRequestMapper and implementation
  • ZeroPaddingIntegerConverter
  • WildcardCollectionModel, WildcardListModel, WildcardSetModel - use the corresponding classes without "Wildcard"-prefix instead
  • PropertyResolver.IClassCache is replaced by PropertyResolver.IPropertyLocator

Improvements

Casting helper Model#of(IModel<?> model)

The helper method for casting of models was moved from Model to IModel#of(IModel<?>).

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.

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

For convenience IRequestHandler class provides a do-nothing implementation of its #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|BiConsumer)  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, org.apache.wicket.model.lambda.WicketFunction and org.apache.wicket.model.lambda.WicketBiFunction. 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 a new implementation of IModel which uses Java 8 consumers and suppliers, i.e. may be used with lambda or method references

  • org.apache.wicket.model.LambdaModel

    LambdaModel
    Person person = ...;
    IModel<String> personNameModel = new LambdaModel<>(
          () -> person.getName(),
          (name) -> person.setName(name));
  • org.apache.wicket.model.LambdaModel with method references

    LambdaModel.of()
    Person person = ...;
    IModel<String> personNameModel = LambdaModel.of(person::getName, person::setName);
  • org.apache.wicket.model.LambdaModel can be created with a target model too - note the upper-case 'P' for the function references:

    LambdaModel.of(target, ...)
    IModel<Person> person = ...;
    IModel<String> personNameModel = LambdaModel.of(person, Person::getName, 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>

Provide LambdaColumn - IColumn implementation that uses java.util.function.Function  Unable to render Jira issues macro, execution error.

LambdaColumn
 columns.add(new LambdaColumn<Contact, String>(new Model<>("Last Name"), "lastName", Contact::getLastName)

IColumn uses Java 8 default interface method for IColumn#isSortable()  Git commit

For convenience IColumn class provides an implementation of #isSortable() method that uses #getSortProperty() to decide. Just like AbstractColumn did until Wicket 7.

IColumn provides methods for column's header rowspan/colspan  Unable to render Jira issues macro, execution error.

New methods have been added to help manipulating the tables' headers: IColumn#getHeaderColspan() and IColumn#getHeaderRowSpan(). Both of them return 1, so the header cells do not span by default.

 

IRequestCycleListener notified of all IRequestHandlers  Unable to render Jira issues macro, execution error.

IRequestCycleListeners are now notified of the execution of all IRequestHandlers, including those scheduled by other handlers, those replacing other handlers, and any handler executed due to an exception:

  • #onRequestHandlerResolved(RequestCycle, IRequestHandler) - any handler to be executed
  • #onRequestHandlerExecuted(RequestCycle, IRequestHandler) - any handler successfully executed without an exception

RequestHandlerStack is now renamed to RequestHandlerExecutor.

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