Daan is a software developer with a strong focus on interaction design. Mainly developing in Java. He likes Agile methodologies, and has worked many years with Scrum. Besides work, he absolutely loves experimenting with new (or old!) technology. Daan's blog can be found at http://stuq.nl. Daan has posted 8 posts at DZone. You can read more from them at their website. View Full User Profile

London Wicket Meetup: Wicket 1.5, WiQuery, Brix and more..

11.27.2009
| 7853 views |
  • submit to reddit
On November 21st the London Wicket meetup took place in “The Gallery” at the central London Foyles Bookshop. At the venue some well-known Wicket-related speakers made their entrance and held talks about Brix, Wicket 1.5, WiQuery, and how having a baby compares to writing a book.

This is the summary of that afternoon. You should have been there…

Keep an eye on this page for when the next London Wicket event is scheduled.

Overview

Click on an item to jump down (same page) to the notes from that presentation.

(Unfortunately Alastair Maw couldn’t make it as he was sick. Hope you will soon be better!)

Cemal Bayramoglu of jWeekend giving the introductory talk for the London Wicket meetup.

Cemal giving the introductory talk

Cemal Bayramoglu: Introduction

As usual, the London Wicket Meetup is kindly hosted by Cemal Bayramoglu of jWeekend. Thanks Cemal!

Jeremy Thomerson showing some code at the London Wicket meetup.

Jeremy Thomerson showing some code

Jeremy Thomerson (USA): Custom JavaScript Integrations with Wicket + Auto Resolvers

Jeremy Thomerson started his talk with an example of how to do client side validation in Wicket. He showed abstract validation behaviors that validated form input with jQuery.

The remarkable thing was that by adding just one behavior to a component, validation was added for both the server side and the client side. This makes it very easy to keep client and server side validation in sync.

The Javascript behavior is added by letting the behavior implement iHeaderContributor and adding the script in the onRenderHead method call.

Auto component resolution

The next part of Jeremy’s presentation was about the AutoComponentResolver. The AutoComponentResolver makes it possible to wire components directly in HTML, without adding the component explicitly in Java. His demo showed how to use an AutoComponentResolver.

Matej Knopp commented that it is not really recommended to use automatic component resolving, because it has a limited use. The main purpose of auto component resolvers is for simple components that do not have a long lifetime on the page. For example the <wicket:message> tag is handled by automatic component resolving and is replaced by a Label with a ResourceModel. More complicated use cases are not supported nor recommended.

Components added via auto-resolving are not serialized or stored in the session and lose all state.

Lionel Armanet showing us the WiQuery goodness at the London Wicket meetup.

Lionel Armanet showing us the WiQuery goodness he and his fellow Frenchmen created.

Lionel Armanet (FR): Announcing WiQuery 1.0: Introduction & Demo

The presentation of Lionel Armanet was an impressive demo of what WiQuery is capable of. WiQuery integrates jQuery with Wicket, with clever tricks that ease development. WickeXt was merged with jQuery4Wicket and changed its name to WiQuery. Last week was the 1.0 release, and the library is available under the MIT license.

The rationale behind WiQuery is that to build rich internet applications, you need rich behaviors and components. jQuery is simple, unobtrusive and powerful, there are tons of plugins and jQuery UI has fancy components. So, let’s get jQuery, integrate it with Wicket and have the best of both worlds!

WiQuery has standard components and behaviors like the resize behavior, drag and drop behavior, datepicker component, etcetera. By simply adding Java components, WiQuery generates the Javascript for you and imports the required libraries.

Setting up WiQuery

There are two ways to setup wiquery:

With a WiQueryCoreInstantiationListener:

addComponentInstantiationListener(new WiQueryInstantiationListener)

Or by extending the Abstract class WiQueryWebApplication.

Demo

After the theory, Lionel showed an impressive demo with a drag-and-drop Scrum taskboard. The task board had three columns (new, in progress, done), from which task items could be dragged and dropped around. Double clicking an item showes the details for that task.

The double click action is easily added with:

add(new WiQueryAjaxEventBehavior(MouseEvent.DBLCLICK){
....
});

With the IThemableApplication interface you can make your application themable, like the themes that jQuery UI has.

Matej Knopp talked about Brix and Wicket 1.5 on the London Wicket meetup

Matej Knopp talked about Brix and Wicket 1.5.

Matej Knopp (SK): BRIX CMS + Wicket 1.5 Developments Q&A

Matej Knopp showed what the content management system Brix is all about. Brix is based on Wicket and is a component based content management system based on JCR for storage.

Brix is meant for integration with Wicket web applications and looks very interesting. The basic building blocks in Brix are Tiles, Pages, and Templates.

In Brix, Tiles are like a factory for embedding Wicket components. So any Wicket component can be added to a Page which is nearly impossible in ‘regular’ CMS systems. More information about Brix can be found on the Brix website.

Wicket 1.5

Matej also talked about some new developments that can possibly be shipped in Wicket 1.5:

  • New RequestCycle
  • New RequestMapper
  • New Ajax implementation

New RequestCycle and RequestMapper

One of the areas where improvements can be made is the RequestCycle. The RequestCycle in Wicket 1.4.x is big and complicated, and hard to step through while debugging. Matej worked on an improved RequestCycle.

Matej talked about the drawbacks of the Wicket 1.4 code for handling requests and mapping requests to URL’s:

  • Complicated, huge code base
  • Many abstractions, most of them on wrong level
  • Complicated class hierarchy, hard to find proper extension point

He proposed a new RequestMapper that handles Request mapping in a different way.

RequestMapper Interface

The RequestMapper will get the following interface.

public interface RequestMapper {
int getCompatibilityScore(Request request);
RequestHandler mapRequest(Request request);
Url mapHandler(RequestHandler requestHandler);
}

With the RequestMapper interface you can implement your own Request Mapping behavior for various URL’s.
There can be a hierarchy of RequestMappers. When there is more than one RequestMapper, the compatibility score can be used to choose which RequestMapper will be used.

Calculating RequestMapper compatibility score

The compatibility score is calculated by counting how many URL segments match the mount point.
For example, having an application where two RequestMappers are defined with these URLs:

  1. /mounted/page
  2. /mounted/page/that/is/different

When there is a new Request on “/mounted/page/that/is/”, the second RequestMapper gets a higher compatibility score (4) than the RequestMapper matching only the first two parts of the URL (”/mounted/page/”).

New AJAX implementation

About a year ago, Matej created a new Ajax implementation for Wicket. The new Ajax implementation is way better than what is now in Wicket 1.4. It is faster, simpler to use and will be based on a standard library. There is only one problem, the new Ajax implementation Matej built uses YUI. It seems that the world prefers jQuery over YUI. Matej told that rewriting it to jQuery will be a lot of work.

The focus of the new Ajax implementation is removing browser inconsistency code. The custom-written Wicket Javascript will be swapped for more standard Javascript (like the YUI or jQuery libraries).

The API for working with Javascript will be different and much cleaner according to Matej. Also, the generated Javascript is nicer: code is not put directly in the onclick of a UI control, but separately. This looks like how WiQuery does stuff. This means that the Javascript handlers are much shorter, so the page loads faster.

There is an experimental branch in source control, so if you want to try it out or convert it to jQuery, you are welcome to check it out.

Problems with implementation Wicket 1.5

There are some challenges with the implementation of Wicket 1.5. Matej touched a few and gave some insight in what needs to be done. The big question is: how to build this without breaking anything? How can we undo the universe?

One point was the use of global state during the 1.4 Wicket RequestCycle. This makes it difficult to implement the new RequestCycle in core, because much code and unit tests rely on this global state.

Another challenge is keeping the WicketTester in a workable state. The new RequestCycle breaks WicketTester, which is problematic because many people are using WicketTester. Fixing WicketTester is not really easy, because it is a big class with much functionality. It can simulate a lot of actions, like file upload and form submission.

Sven Meier encouraged us to not refrain from writing custom Javascript on the London Wicket meetup

Sven Meier encouraged us to not refrain from writing custom Javascript.

Sven Meier (DE):

Sven Meier showed us his implementation of a TreeModel. He argued that Swing’s TreeModel is not suitable for implementing a tree in Wicket: “The treemodel is ugly, and there are many methods you don’t need in Wicket.”

His implementation allows hierarchical markup in the tree. This makes it easier to use and extend. It uses simple and known patterns. Partial update is not there yet.

Google Code hosts the Wicket Tree project.

Drag and drop

Sven also created Wicket drag and drop functionality, which is also hosted at Google Code.

This project enables you to drag and drop between any Wicket component. It supports common desktop metaphors with ‘MOVE’, ‘COPY’ and ‘LINK’ operations and is fully themable.

Sven’s closing remarks were: “Don’t fret from developing custom Javascript. It’s really easy with Wicket!”

Martijn Dashorst compared having a baby to writing a book on the London Wicket meetup

Martijn Dashorst compared having a baby to writing a book.

Martijn Dashorst (NL):

Martijn’s presentation was titled “Writing Books vs Making Babies” and was a hilarious story with good slides. We have been informed of all the gory details of writing a book (finding the publisher, writing, editing, checking, etcetera) and learned something about having a baby as well!

Wicket Q&A

There were not many questions about Wicket, which is proof for the developer friendliness of Wicket ;-)

Were you there?

If you were at the London Wicket meetup (presenter or attendee) or plan to go there next time, please comment below!

If you send me links to the presentations, I will add them to the article.

References
Published at DZone with permission of its author, Daan van Etten. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)