A page in my Wicket app has a contructor which should access an injected repository, but the repository is injected not until construction is complete..
public class ArticlePage extends WebPage { @SpringBean private static ArticleRepository repository; // initialized after construction! private Article article; public ArticlePage() { this(repository.findByName("index")); // NullPointerException here } public ArticlePage(Article article) { add(new Label("name", new PropertyModel(article, "name"))); add(new Label("contentHtml", new PropertyModel(article, "contentHtml"))); add(new Label("revision", new PropertyModel(article, "revision"))); add(new Label("revisionDate", new PropertyModel(article, "revisionDate"))); add(new Label("author", new PropertyModel(article, "author"))); } } This code looks for the default page in a database an passes it to the real constructor. But this is only a footnote because the problem is more general. How do I access injected objects within a constructor? When I try to access "repository" I get a NullPointerException because this field is initialized after construction. The reason is that the Spring integration in Wicket does not allow constructor injection. How can solve this problem? Is Wicket+Spring (or DI in general) really a good combination? It seems again and again improper to me. Thanks for help! Christian -- http://www.groovy-forum.de --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org