I'm not sure this is done right, but here is what I did and the problem I'm
having:
There is MyApplication that's somehow instantiated by
GuiceWebApplicationFactory via web.xml:
<filter>
<filter-name>my</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>applicationFactoryClassName</param-name>
<param-value>org.apache.wicket.guice.GuiceWebApplicationFactory</param-value>
</init-param>
<init-param>
<param-name>module</param-name>
<param-value>com.synformation.wicket.my.MyGuiceModule</param-value>
</init-param>
</filter>
MyGuiceModule.java:
public class MyGuiceModule implements Module {
public void configure(Binder binder) {
binder
.bind(WebApplication.class)
.to(MyApplication.class);
binder
.bind(IAddress.class)
.to(Address.class);
}
This works since I see the pages of MyApplication without a problem. Also,
I've set a breakpoint in configure() where I see that my implementations are
bound to the interfaces. So GuiceWebApplicationFactory pulls MyApplication
out of MyGuiceModule.
Next, I try to inject an Address into the Cart class:
@Inject
private IAddress address;
...
public IAddress getAddress() {
return address;
}
My Wicket page tries to access it:
IAddress address = cart.getAddress();
form.add(new TextField("name", new PropertyModel(address, "name")));
I get an exception. Part of stack trace:
java.lang.IllegalArgumentException: Parameter modelObject cannot be null
at
org.apache.wicket.model.AbstractPropertyModel.<init>(AbstractPropertyModel.java:66)
at org.apache.wicket.model.PropertyModel.<init>(PropertyModel.java:99)
The object returned by getAddress() is null. It seems that the Address
object never gets injected.
--
View this message in context:
http://www.nabble.com/Problem-with-Wicket-and-Guice-tp14787021p14787021.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]