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

Igor Vaynberg resolved WICKET-2781.
-----------------------------------

    Resolution: Won't Fix
      Assignee: Igor Vaynberg

> Support @SpringBean injection into generic superclass
> -----------------------------------------------------
>
>                 Key: WICKET-2781
>                 URL: https://issues.apache.org/jira/browse/WICKET-2781
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-spring
>    Affects Versions: 1.4.7
>            Reporter: Erkki Lindpere
>            Assignee: Igor Vaynberg
>            Priority: Minor
>         Attachments: wicket-spring-inject-patch.txt
>
>
> It's possible to inject Spring Beans into a generic superclass, if the field 
> type to be injected is a type variable. I will attach a patch that does this 
> (I don't know if it's the best or most general implementation, but it works 
> in my case). This allows us to reduce code in a wicket-spring project and it 
> would be great if you could integrate this change into wicket-spring.
> This also allows better integration with Scala because it seems Scala 
> initialization order is different enough from Java that it seems impossible 
> to make a variable injected into a subclass of a generic superclass available 
> to the generic superclass's constructor.
> Simplified example for the motivation:
> public abstract class EditPage<EntityType, RepoType extends 
> IRepository<EntityType>> {
>   @SpringBean
>   RepoType repository;
>   ...
> }
> Concrete "edit pages" extend this and define EntityType and RepoType. 
> Injecting in the superclass allows the subclasses to be very thin, which is 
> great. I was not able to implement this in Scala (maybe there's some trick 
> but I don't know), even if I replace the repostiory with: protected abstract 
> RepoType getRepository() and implement this in a Scala subclass:
> class UserEditPage extends EditPage<User, UserRepo> {
>   @SpringBean
>   var repo: UserRepo = _
>   def getRepository = repo
> }
> when the superclass' constructor calls getRepository, it will get null (and 
> sometimes method not found getRepository: IRepository, but that might be due 
> to JRebel)

-- 
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