Apache Wicket Java 8 upgrade only partially supports lambdas – Info Web Dev
The new Version 8 of the Apache Wicket open source Java framework embraces Java 8, including types. But use of lambda expressions, the marquee feature of Java 8, is supported only in parts of the framework.
As of Version 8, the server-side, component-oriented Wicket web framework supports Java 8 idioms, with Java 8’s idioms and types applied to the Wicket API. It also has new types to handle dates in Java 8, which can be converted and bound to components.
Why Wicket only partially supports lambdas
Wicket’s developers decided against supporting lambdas in the API because of performance and memory usage considerations. Thus, subclassing remains the primary extension mechanism for Wicket components. A typical Wicket application has many components in memory at any given time, and keeping references to lambdas would considerably increase this memory footprint, said Martijn Dashorst, vice president of Apache Wicket at the Apache Software Foundation.
But Wicket 8 does provide factories for lambdas for forms of models and behaviors. A factory in Wicket is a design pattern for creating objects, enabling Wicket-specific functionality. Also, the root interface model has been made a functional interface; models are the data-binding method in the framework. As a result, developers can use lambdas where they use models.
LambdaModel type in Wicket 8 enables type- and refactor-safe databinding for components. Previously, data would be bound to components via
PropertyModel, using a string expression to determine which property to show.
LambdaModel can make it easy for IDEs to perform refactoring.
Other new features in Wicket 8
Other features of Wicket 8 include:
- Adoption of Java 8’s Optional type, to clarify the API. This type is intended for use in an API in places where things can be null. Wicket’s AjaxFallbacklink, for example, now uses Optional to signify whether a link was clicked using AJAX or normal request processing.
- Entire Wicket applications do not need to be rewritten to support Java 8. Dashort said migrating a typical Wicket application with 30,000 lines of Java code and 100 pages took about a half day.
- Removal of many deprecated features from prior versions.
Where to download Apache Wicket 8
You can download Wicket 8 from a mirror of the project website.
Article Prepared by Ollala Corp