wicket @SpringBean 无法创建 bean
我有一个关于 Eclipse、Wicket、Spring、Hibernate 的项目。一切正常,除了:当我尝试
public class SortableContactDataProvider extends SortableDataProvider<User>
{
@SpringBean
private Service service;
public Iterator<User> iterator(int first, int count)
{
//SortParam sp = getSort();
return service.findAllUsers().subList(0, 15).iterator();
}
...
服务变量为空?在任何其他地方,当我使用此构造“服务”时,它不为空并且运行良好。请帮我解决这个问题。
I have a project on Eclipse, Wicket, Spring, Hibernate. Every thing works normaly except : when I try
public class SortableContactDataProvider extends SortableDataProvider<User>
{
@SpringBean
private Service service;
public Iterator<User> iterator(int first, int count)
{
//SortParam sp = getSort();
return service.findAllUsers().subList(0, 15).iterator();
}
...
the service variable is null? In any another places when I use this constuction "service" is not null and working well. Please help me to solve this problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@SpringBean仅适用于组件的任何子类。
中执行以下操作,
您需要在构造函数Wicket 1.4
Wicket 1.5+
请参阅“通用 IDataProvider 实现”@ http://stronglytypedblog.blogspot.com/2009/03/wicket-patterns-and-pitfalls-1.html
享受
@SpringBean works only in any Subclass of Component.
You need to do the following in your Constructor
Wicket 1.4
Wicket 1.5+
See 'generic IDataProvider implementation' @ http://stronglytypedblog.blogspot.com/2009/03/wicket-patterns-and-pitfalls-1.html
Enjoy
对于那些 Wicket/Spring 环境的新手来说,有更多的上下文 - 正如 bert 所指出的,@SpringBean 仅适用于组件的任何子类,因此您需要手动驱动注入。这是一个 2 步过程:
在您的类中驱动注入,如下所示:
并确保在 Wicket 应用程序中设置注入器 - 类似于:
A bit more of context for those who are newbies to Wicket/Spring environment - as bert, pointed out, @SpringBean works only in any Subclass of Component so you'll need to drive the injection manually. This is a 2 step process:
Drive the injection in your class, something as:
And make sure the Injector is set up in Wicket application - something like: