Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wicket @SpringBean can not create bean

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.

like image 916
Daler Avatar asked Jul 09 '10 07:07

Daler


Video Answer


1 Answers

@SpringBean works only in any Subclass of Component.

You need to do the following in your Constructor

Wicket 1.4

  InjectorHolder.getInjector().inject(this);

Wicket 1.5+

  org.apache.wicket.injection.Injector.get().inject(this);

See 'generic IDataProvider implementation' @ http://stronglytypedblog.blogspot.com/2009/03/wicket-patterns-and-pitfalls-1.html

Enjoy

like image 92
bert Avatar answered Nov 15 '22 20:11

bert