a) dont start a new thread for the same problem
b) you dont need this InjectorHolder.getInjector().inject(this); since
your repository is no longer abstract.

-igor

On Sat, Feb 28, 2009 at 11:29 AM, Christian Helmbold
<christian.helmb...@yahoo.de> wrote:
> I've found a workaround. Not elegant, but it works:
>
> public class ArticlePage extends WebPage
> {
>   �...@springbean
>    private ArticleRepository repository;
>    private Article article;
>
>    public ArticlePage()
>    {
>        InjectorHolder.getInjector().inject(this);
>        construct(repository.findByName("index"));
>    }
>
>    private void construct(Article article)
>    {
>        add(new Label("name", new PropertyModel(article, "name")));
>        //...
>    }
>
> }
>
> It looks a bit better than service locator pattern but not much. Any other 
> suggestions?
>
> Regards
> Christian
>
> --
> http://www.groovy-forum.de
>
>
>
> ----- Ursprüngliche Mail ----
>> Von: Christian Helmbold <christian.helmb...@yahoo.de>
>> An: users@wicket.apache.org
>> Gesendet: Samstag, den 28. Februar 2009, 20:14:02 Uhr
>> Betreff: AW: NullPointerExceptions due to missing Spring constructor 
>> injection
>>
>> 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
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

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

Reply via email to