[ 
https://issues.apache.org/jira/browse/WICKET-1690?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12603588#action_12603588
 ] 

Thomas Eckoldt commented on WICKET-1690:
----------------------------------------

InjectorHolder.getInjector().inject(this) 

doesn't work for wicket-guice, or is there something more to consider?

> Allow injection of models
> -------------------------
>
>                 Key: WICKET-1690
>                 URL: https://issues.apache.org/jira/browse/WICKET-1690
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-guice
>            Reporter: Thomas Eckoldt
>            Assignee: Igor Vaynberg
>
> wicket-guice allows injection of components in a very transparent way - this 
> should work the same way for models. In particular when working with 
> loadable, detachable models it is desirable to inject a service 
> implementation that is responsible for loading the model data. If such a 
> model (see example code below) is not declared as nested class of a component 
> but as a top-level class for reuse, model injection is needed.
> Example:
> {code}
> public class ContactModel extends LoadableDetachableModel {
>       private Long contactId;
>       
>       @Inject
>       private ContactService service;
>       
>       public ContactModel(Long contactId) {
>               this.contactId = contactId;
>       }
>       
>       @Override
>       protected Contact load() {
>               return service.getContact(contactId);
>       }
> }
> {code}

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