How to populate Wicket @SpringBeans in Scala?

I have a wicket Pagewith@SpringBean

class ScreenDetailsPage(parameters: PageParameters) extends BasePage(parameters) {
    @SpringBean(name = "screenDAO") protected var screenDao: DAO[Screen] = null
    assertNotNull(screenDao)

and I found that @SpringBean is not populated. It does not matter if it screenDaois val or var, protected or private.

By raising the tree, I find that the constructor Component(indirectly) initializes @SpringBeanon behalf of its subclasses, but then the null assignment is non-initialization. But an appointment is required by Scala.

How can I prevent this behavior?

+3
source share
1 answer

Try

class ScreenDetailsPage(parameters: PageParameters) extends BasePage(parameters) {
    @SpringBean(name = "screenDAO") protected var screenDao: DAO[Screen] = _
    assertNotNull(screenDao)

I have not tried this, but I am also thinking about starting the Wicket / Scala project and saw this blog post which may be useful in other ways as well.

The relevant section listed on this blog,

, , (_), Scala , ( - null). , . null, Spring bean, , MyPage.

+6

All Articles