|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Getting InstanceContent from LookupHi!
Does anyone know if something like this is possible? InstanceContent instanceContent=new InstanceContent(); AbstractLookup abstractLookup=new AbstractLookup(instanceContent); ... myObject.getLookup().lookup(InstanceContent.class).add(myAddedObject); .... It does not work in this way becaus AbstractLookup doesn't save the instance content object in its lookup. I just want to understand how to add objects to lookups dynamically.. Thanks, BYe, Klaus |
|
|
Re: Getting InstanceContent from LookupWell, I think the Lookup isn't supposed to be used like that from an designer's perspective. It's not a bag of objects where anyone external can just add/remove stuff (although it can be used like this).
It's more of a way for "myObject" to expose his capabilities. So, some normal usage would be: myObject.doSomething(myAddedObject) which *internally* might do something similar to instanceContent.add(myAddedObject) but it also might do something else that changes his lookup. If you really want to use your code the way you wrote it, bear in mind that the InstanceContent isn't *added* to the lookup, so you can't search for it. InstanceContent *is* the model for the AbstractLookup class and you basically have to keep a reference to it somewhere if you want to change the lookup (for example myObject.getInstanceContent().add(myAddedObject) would do the trick although it's an ugly API). --emi On Sat, Jul 4, 2009 at 1:56 PM, Klaus Martinschitz <klausmartinschitz@...> wrote: Hi! -- Emilian Bold http://www.emilianbold.ro :Java and NetBeans Platform-loving development from Timisoara, Romania. http://www.josekibold.ro : Java / iPhone development. |
|
|
Re: Getting InstanceContent from LookupI have used this on multiple projects successfully: http://wadechandler.blogspot.com/2007/12/central-lookup-creating-central.html Of course, the way you are doing it, you could probably add the InstanceContent to itself and that work the way you are trying. I think at that point it would just be a self reference. Wade Wade Chandler, CCE Software Engineer and Developer Certified Forensic Computer Examiner NetBeans Dream Team Member and Contributor http://www.certified-computer-examiner.com http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam http://www.netbeans.org
|
| Free embeddable forum powered by Nabble | Forum Help |