如何在 Scala 中填充 Wicket @SpringBeans?
我有一个带有 @SpringBean
的 Wicket Page
class ScreenDetailsPage(parameters: PageParameters) extends BasePage(parameters) {
@SpringBean(name = "screenDAO") protected var screenDao: DAO[Screen] = null
assertNotNull(screenDao)
,但我发现 @SpringBean 未填充。 screenDao
是 val 或 var、protected 或 private 都没有区别。
查找树,我发现 Component
的构造函数(间接)代表其子类初始化 @SpringBean
s,但随后对 null 的赋值将取消初始化它。但 Scala 要求进行赋值。
我怎样才能防止这种行为?
I have a Wicket Page
with a @SpringBean
class ScreenDetailsPage(parameters: PageParameters) extends BasePage(parameters) {
@SpringBean(name = "screenDAO") protected var screenDao: DAO[Screen] = null
assertNotNull(screenDao)
and I find that the @SpringBean is not populated. It makes no difference if screenDao
is val or var, protected or private.
Looking up the tree I find that the constructor of Component
(indirectly) initialises @SpringBean
s on behalf of its subclasses, but then the assignment to null is uninitializing it. But the assignment is required by Scala.
How can I prevent this behaviour?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试一下
我还没有尝试过这个,但我也在考虑启动一个 Wicket/Scala 项目,并看到 此博客条目,它在其他方面也可能有用。
该博客引用的相关部分是
Try
I have not tried this, but am also thinking about starting a Wicket/Scala project, and saw this blog entry, which might be useful in other ways as well.
The relevant section quoted from that blog is