Paul Krill
Editor at Large

Apache Wicket Java 8 upgrade only partially supports lambdas

news
May 25, 20182 mins

The open source Java web framework continues to subclasses for extensions, due to memory and performance issues

coffee cup - coffee beans - Java
Credit: Christoph

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.

The 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.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author