问题描述
我有一个关于Eclipse,Wicket,Spring,Hibernate的项目。除了以下内容之外,每件事情都是正常的:当我尝试
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.
推荐答案
@SpringBean只能在Component的任何Subclass中使用。
@SpringBean works only in any Subclass of Component.
您需要在构造函数中执行以下操作
You need to do the following in your Constructor
Wicket 1.4
Wicket 1.4
InjectorHolder.getInjector().inject(this);
Wicket 1.5 +
Wicket 1.5+
org.apache.wicket.injection.Injector.get().inject(this);
参见'通用IDataProvider实施'@
See 'generic IDataProvider implementation' @ http://stronglytypedblog.blogspot.com/2009/03/wicket-patterns-and-pitfalls-1.html
享受
这篇关于wicket @SpringBean无法创建bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!