Guice & Wicket, a perfect match.
You know
Wicket , at least, you’ve heard of it. What you might have missed, is that it integrates with
Guice quite well through
this project .
I’ve tried it and it’s marvellous. Consider this:
SomeForm.java
public final class SomeForm extends Form
{
public SomeForm(final String componentName)
{
super(componentName);
add(new FeedbackPanel("feedback"));
[... populate form ...]
}
// this is where it gets guicy:
@Inject
private AuditService auditService;
@Override
public final void onSubmit()
{
auditService.doSomeAuditing(...);
doSomethingImportant();
}
[...]
}
The beauty of this is the fact, is that this still works with Serialized forms (of course) and that together with Maven, you have a really good setting for prototyping with Wicket.
Just create your Wicket project, start prototyping your wicket GUI using mvn jetty:run and create/modify Service-interfaces as needed accompanied by Prototype-Implementations (aka NOP-Impls ).
You can later implement your Services for real and just plug them in by switching the Guice-Module:
AbstractWebApplication.java
public abstract class AbstractWebApplication extends WebApplication
{
@Override
protected void init()
{
super.init();
addComponentInstantiationListener(
new GuiceComponentInjector(this,getModule());
}
private Module getModule()
{
return isPrototyping() ?
getPrototypingModule() : getRuntimeModule();
}
protected Module getPrototypingModule()
{
return new Module()
{
public void configure(final Binder binder)
{
binder.bind(AuditService.class).
toInstance(new AuditingServicePrototype());
[...]
}
};
// you get the idea.
}
}
Lightweight prototyping – Dependencies injected – no XML
plus
Guice-Scopes are available to give you further flexibility of Object creation.
I love it!

