Oh okay. I've been trying to use @SpringBean which of course didn't work because EntityModel is not a component. Thanks alot!
On Thu, 2009-11-12 at 09:02 +0100, Matthias Keller wrote: > Injection is easy > > Just call: > InjectorHolder.getInjector().inject(this); > in your EntityModel constructor. > > That's it. > While developing if you hot-redeploy often, you might also want to do a > check in load() like: > if (this.whateverService == null) > InjectorHolder.getInjector().inject(this); > > Matt > > Sam Barrow wrote: > > Yes that shouldn't be a problem I just need to figure out the injection, > > how do you do this? I use wicket-spring also. > > > > On Thu, 2009-11-12 at 08:53 +0100, Matthias Keller wrote: > > > >> Hi Sam > >> > >> We use Spring to inject them. > >> Well, somewhere you'll need that logic what class is loaded by which > >> repo - you could of course do it in a more generic way using factories > >> or a kind of a mapper or whatever... > >> Since we only have around 10 classes, this is easy. > >> > >> If you use hibernate, you can have it for free since you can instruct > >> hibernate to load the instance given the class and the id, for example: > >> T entity = entityManager.find(entityClass, id); > >> > >> Matt > >> > >> Sam Barrow wrote: > >> > >>> We have close to a hundred repositories, this wouldn't work. How do you > >>> inject the services into the EntityModel anyway? > >>> > >>> On Thu, 2009-11-12 at 08:34 +0100, Matthias Keller wrote: > >>> > >>> > >>>> Hi Sam > >>>> > >>>> What exactly do you mean by repository? Do you have to load every entity > >>>> from another place? > >>>> in load(), we have the code to load every possible entity in our > >>>> implementation, for example: > >>>> > >>>> T entity; > >>>> if (this.clazz == User.class) { > >>>> entity = userService.load(...); > >>>> } else if (this.clazz == Company.class) { > >>>> entity = companyService.load(...); > >>>> } else ..... > >>>> > >>>> And so on. In the end, the entity is loaded from wherever it is defined > >>>> for this class... > >>>> > >>>> Matt > >>>> > >>>> Sam Barrow wrote: > >>>> > >>>> > >>>>> Does anybody how to pass a smart EntityModel (link below) to another > >>>>> page? We use a different repository for each entity type. I can't get it > >>>>> to work. I have tried storing the repository as a field on the > >>>>> EntityModel and using an abstract method on EntityModel to retrieve it. > >>>>> > >>>>> http://wicketinaction.com/2008/09/building-a-smart-entitymodel/ > >>>>> > >>>>> > >>>>> > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org