Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » Binding through several instances?
Binding through several instances? [message #759633] Tue, 29 November 2011 12:20 Go to next message
membersound is currently offline membersound
Messages: 5
Registered: November 2011
Junior Member
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
Re: Binding through several instances? [message #764591 is a reply to message #759633] Mon, 12 December 2011 13:45 Go to previous message
Andrey Sablin is currently offline Andrey Sablin
Messages: 12
Registered: March 2011
Junior Member
BeansObservables not allowed using dot-separeter property names for observe lists, sets and maps (its allowed only for observe single values).

Using followed template is INCORRECT:
Target (Widget) = listViewer, input
Model (Bean) = controller, model>personList
index.php/fa/6437/0/


CORRECT template to use is:
Target (Widget) = listViewer, input
Model (Bean) = controller>model, personList
index.php/fa/6436/0/

PS Trunk fixed for disabling button "Create binding" for incorrect template.
  • Attachment: incorrect.png
    (Size: 186.75KB, Downloaded 471 times)
  • Attachment: correct.png
    (Size: 187.31KB, Downloaded 475 times)

[Updated on: Mon, 12 December 2011 13:48]

Report message to a moderator

Previous Topic:Exception parsing a form composite whose constructor contains additional parameters.
Next Topic:WindowBuilder Design Mode changes parent when moving objects
Goto Forum:
  


Current Time: Sat Oct 25 01:36:35 GMT 2014

Powered by FUDForum. Page generated in 0.02282 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software