[ 
https://issues.apache.org/jira/browse/WICKET-2476?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dominik Drzewiecki updated WICKET-2476:
---------------------------------------

    Summary: SpringBean annotated fields are not reinjected when the same 
instance of the component is being reused.  (was: SprinBean annotated fields 
are not reinjected when the same instance of the component is being reused.)

> SpringBean annotated fields are not reinjected when the same instance of the 
> component is being reused.
> -------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-2476
>                 URL: https://issues.apache.org/jira/browse/WICKET-2476
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-spring
>    Affects Versions: 1.4.1
>            Reporter: Dominik Drzewiecki
>             Fix For: 1.4.2
>
>
> SpringBean annotated components' fields get injected on instantiation only 
> (well, that's when the IComponentInstantiationListener implementations are 
> supposed kick in), while they are left as-is on subsequent reusage of the 
> same component (e.g. when Page instance is retrieved from the pageMap rather 
> than being instantiated). This behavior leads to the wrong instances of beans 
> being available as reused components injected fields whenever the scope of 
> the bean is declared as "prototype" or "request" (or some other scope 
> narrower than "session"). A glimpse at the wicket guts led me to the 
> hypothesis that this problem might be solved by additionally implementing 
> IComponentOnBeforeRenderListener and registering it using 
> addPreComponentOnBeforeRenderListener(). How about: 
> package org.apache.wicket.injection;
> public class ComponentInjector implements IComponentInstantiationListener, 
> IComponentOnBeforeRenderListener 
> {
>       public void onInstantiation(Component component) {
>               getInjector().inject(component);
>       }
>         .....
>       public void onBeforeRender(Component component) {
>               getInjector().inject(component);
>       }
> }
> and then in Application's init()
>       ComponentInjector injector = new SpringComponentInjector(this);
>       addComponentInstantiationListener(injector);
>       addPreComponentOnBeforeRenderListener(injector);
> My initial observations prove that the injector.inject() should also 
> correctly address the case whenever the instance had already been injected 
> with the proxy (otherwise field.get(object) call fails)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to