You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Christian Helmbold <ch...@yahoo.de> on 2009/02/28 20:48:35 UTC

AW: NullPointerExceptions due to missing Spring constructor injection - Solution

Excuse my bit by bit mailings but I don't want to keep the solution secret. The problem with my first try was the missing implicit call to super() within the constructor because I used this() instead. The line
InjectorHolder.getInjector().inject(this);
is not necessary when I put the code in a separate method. this works:

public class ArticlePage extends WebPage
{
    @SpringBean
    private ArticleRepository repository;
    private Article article;

    public ArticlePage()
    {
        // no need to use InjectorHolder here
        construct(repository.findByName("index"));
    }

    private void construct(Article article)
    {
        add(new Label("name", new PropertyModel(article, "name")));
        // ...
    }

}

Is there something left to be improved?

Dependency Injection seems to be a bit tricky with wicket. Maybe something for the second edition of wicket in action ...

Regards
Christian

-- 
http://www.groovy-forum.de


      


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org