Christian, It sounds like you're sinking fast into some quicksand you've created in your mind - partly because you don't trust, Wicket, Spring, the Wicket-Spring integration or even Java yet! Your question has nothing to do with Wicket, Spring or Wicket-Spring integration.
First of all, forget every assumption and deduction in your original post on this thread (none is correct). Even if you don't have have time to experiment with Spring DI, have another read of the http://cwiki.apache.org/WICKET/spring.html Wicket-Spring Wiki page and see the http://wicketstuff.org/confluence/display/STUFFWIKI/wicket-phonebook phone book example . Reading up about object initialisation in Java (especially implicit superclass constructor calls) may clear a few things up too. Once you're familiar with standard usage patterns of Spring DI and then Wicket's Spring integration, I'm sure you'll appreciate how very "proper" Wicket-Spring integration actually is; bear in mind that this is used in a lot of production systems, and it "just works", very nicely. Here's a solution to your problem (I'll assume you chose to have a null constructor because you need bookmarkable links) - @SpringBean private ArticleRepository repository; public ArticlePage() {this(null);} public ArticlePage(Article article){ article = article==null?repository.findByName("index"):article; add(new Label("name", new PropertyModel(article, "name"))); ... } Does that make sense? Regards - Cema http://jWeekend.com jWeekend christian.helmbold wrote: > > Hi Martjin, > > it is not possible to compile the code without static. Without static I > get the compiler error: "cannot reference repository before supertype > constructor has been called". But I cannot write > public ArticlePage() > { > super(); > this(); > } > because each of them must be the first statement in the constructor. And I > cannot inject the reference directly into the constructor because of the > mentioned restriction of Wickets Spring integration (no constructor > injection). > > The only way out of this dilemma seems to be not to inject the repository. > But if I cannot use injected reference within constructors I don't know > why I should use Dependency Injection (DI). The constructors are very > important in most classes of Wicket applications. I could use the the > service locator pattern with it's pros and cons. But I hope there is a > solution with DI ... > > Regards > 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 > > > -- View this message in context: http://www.nabble.com/NullPointerExceptions-due-to-missing-Spring-constructor-injection-tp22263431p22265963.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org