Wicket 6.20, problem with injection in onSubmit

29 views
Skip to first unread message

Stepan Samarin

unread,
Aug 5, 2015, 8:27:31 AM8/5/15
to google-guice
Hello,

There's a problem with injection when onSubmit of the Form is invoked. 
Scenario is the following:
Wicket (6.20) page or panel with the field "manager" with @Inject annotation.

Form is created as an anonymous class in onInitialize method of the page. onSubmit method of the form then refers to manager field of the parent page.
Occasionally access to "manager" failed with NPE.

So far the solution was to use: Injector.injectMembers(manager); in onSubmit method.

But there's probably something I'm missing.

Would appreciate help/advice.

Thanks, Stepan.

Stephan Classen

unread,
Aug 5, 2015, 9:31:27 AM8/5/15
to google...@googlegroups.com
Wicket may serialize Form and Page objects. When deserializing them dependencies which aren't serializable will end up null.
Reply all
Reply to author
Forward
0 new messages