You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Igor Vaynberg (JIRA)" <ji...@apache.org> on 2008/06/09 16:51:45 UTC
[jira] Resolved: (WICKET-1690) Allow injection of models
[ https://issues.apache.org/jira/browse/WICKET-1690?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Igor Vaynberg resolved WICKET-1690.
-----------------------------------
Resolution: Won't Fix
Assignee: Igor Vaynberg
in the constructor of your model add this line:
InjectorHolder.getInjector().inject(this);
we cant transparently inject any class since that would require bytecode instrumentation. components have a special facility built in for that in their constructor, but imodel is an interface...
> 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.