On Wednesday 14 February 2007 16:48, Eelco Hillenius wrote: > Imo, once you get used to it, working with callbacks/ factories like > that is actually nice.
Perhaps. I am not so convinced... The interesting bit is that we can find other ways as well. > > Eelco, we have the impression that the stuff that is stored in the > > ListView model will be serialized, in which case the above can not work, > > and a PaxTag mapping or similar would be needed. Could you clarify a bit? > > Yep. Keep in mind that Wicket doesn't have to serialize components at > all; it mostly depends on whether and how you do clustering Isn't it involved in long-running sessions as well?? > This generally can be summed up with these two points: > 1) Use detachable models, such as LoadableDetachableModel. Have to look into these provider stuff in greater detail. Perhaps getting involved in more complex applications would do me good ;o) > public class MyPanel extends Panel { > > @SpringBean private MyService service; > > public MyPanel(MarkupContainer parent, String id) { > IModel theModel = new LoadableDetachableModel() { > protected Object load() { > return service.findAWholeBunchOfVeryCoolDomainObjects(); > } > } > ... > } > } > > Here, @SpringBean (from the wicket-spring project) will result in > service being assigned a proxy, Doesn't this end up with a single Spring application context?? I.e. another form of bridging with singletons. > Btw, @SpringBean works really great, I'm totally hooked on it, even > though I've never been a Spring kiddie. How about an OSGi variant of > this. Any options/ ideas? Well; As you probably know, OSGi is not so much about magic. So, a simple pattern more or less equivalent to the above; public class MyPanel extends Panel { public MyPanel(MarkupContainer parent, String id) { IModel theModel = new LoadableDetachableModel() { protected Object load() { MyService service = MyActivator.getMyService(); return service.findAWholeBunchOfVeryCoolDomainObjects(); } } ... } } And in the BundleActivator we have something like; public void start( BundleContext bc ) { m_myService = new DefaultMyServiceTracker( bc ); } static MyService getMyService() { return m_myService; } The DefaultMyServiceTracker is MyService proxy that tracks the "real thing", and has some behaviour for handling "unavailable". > 2) Be careful with instance variables and inner classes. Keep in mind > that e.g. an anonymous always keeps a reference to it's parent Yep. Very well aware of those traps ;o) Thanks for your feedback... Cheers Niclas _______________________________________________ general mailing list general@lists.ops4j.org http://lists.ops4j.org/mailman/listinfo/general