Binding through several instances? [message #759633] |
Tue, 29 November 2011 12:20  |
Eclipse User |
|
|
|
Hi,
how can I bind a LinkedList to a ListViewComponent through several model-layers? Eg:
Create a controller class within the ApplicationWindow, create a new Model object within the controller, and create a new LinkedList within the model.
public class MainWindow extends ApplicationWindow {
private Controller controller = new Controller();
//...
}
public class Controller extends AbstractModelObject {
private Mode model = new Model();
//getter + setter
}
public class model extends AbstractModelObject {
private List<Person> personList = new LinkedList<Person>();
//getter + setter
}
public class Person extends AbstractModelObject {
String name;
int age;
//getter + setter
}
NOW: I tried the visual binding to the listViewer by selecting:
Target (Widget): listViewer, input
Model (Bean): controller, model>personList
which generates me the following code:
IObservableList controllermodelpersonListObserveList = BeansObservables.observeList(Realm.getDefault(), controller, "model.personList");
listViewer.setInput(controllermodelpersonListObserveList);
BUT running it throws UE:
java.lang.IllegalArgumentException: Could not find property with name model.personList in class class gui.Controller
at org.eclipse.core.internal.databinding.beans.BeanPropertyHelper.getPropertyDescriptor(BeanPropertyHelper.java:182)
at org.eclipse.core.databinding.beans.BeanProperties.list(BeanProperties.java:314)
at org.eclipse.core.databinding.beans.BeansObservables.observeList(BeansObservables.java:322)
at org.eclipse.core.databinding.beans.BeansObservables.observeList(BeansObservables.java:276)
at gui.MainWindow.initDataBindings(MainWindow.java:258)
at gui.MainWindow.createContents(MainWindow.java:131)
at org.eclipse.jface.window.Window.create(Window.java:431)
at org.eclipse.jface.window.Window.open(Window.java:790)
at gui.MainWindow$1.run(MainWindow.java:183)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at gui.MainWindow.main(MainWindow.java:178)
What can I do to fix this? Am I doing wrong with my setup?
Further I noticed: IF I would not create the controller-bean in the AppWindow class, but would create the model-bean directly, THEN I could select "model, personList" for binding and everything works fine!
But as I need the controller in front of the model, how can I do this?
Thanks
|
|
|
|
Powered by
FUDForum. Page generated in 0.06005 seconds