Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XWT » Binding to an object instance rather than to one of its properties
Binding to an object instance rather than to one of its properties [message #1220447] Wed, 11 December 2013 14:26 Go to next message
Sharon Dagan is currently offline Sharon Dagan
Messages: 12
Registered: November 2013
Junior Member
My EMF domain looks something like this:

Bookstore {
  Book[] books
  ...
}


How do I bind an instance of Bookstore, which is my top level object to the input of a JFace viewer?
i.e.,

<ListViewer input="{Binding Path=this}">


Rather than

// this works
<ListViewer input="{Binding Path=books}">


Thanks,
-S.
Re: Binding to an object instance rather than to one of its properties [message #1220449 is a reply to message #1220447] Wed, 11 December 2013 14:39 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal Karaca
Messages: 725
Registered: July 2009
Senior Member
You would have to introduce a wrapper (domain) class and use an instance of that as your data context. You can either model this explicitly (if your Bookstore has no container) or create a simple POJO/Bean:

class BookstoreWrapper {
Bookstore bookstore;
...
}

Keep in mind that a ListViewer is suited to showing one of many options in a list.
I assume you have multiple Bookstores that have to be shown in the ListViewer?

Sharon Dagan wrote on Wed, 11 December 2013 20:26
My EMF domain looks something like this:

Bookstore {
  Book[] books
  ...
}


How do I bind an instance of Bookstore, which is my top level object to the input of a JFace viewer?
i.e.,

<ListViewer input="{Binding Path=this}">


Rather than

// this works
<ListViewer input="{Binding Path=books}">


Thanks,
-S.

Re: Binding to an object instance rather than to one of its properties [message #1220451 is a reply to message #1220449] Wed, 11 December 2013 14:42 Go to previous message
Erdal Karaca is currently offline Erdal Karaca
Messages: 725
Registered: July 2009
Senior Member
BTW. that works because XWT can automatically detect what Databinding to use (POJO/Bean/EMF) and you can mix them.

Erdal Karaca wrote on Wed, 11 December 2013 20:39
You would have to introduce a wrapper (domain) class and use an instance of that as your data context. You can either model this explicitly (if your Bookstore has no container) or create a simple POJO/Bean:

class BookstoreWrapper {
Bookstore bookstore;
...
}

Keep in mind that a ListViewer is suited to showing one of many options in a list.
I assume you have multiple Bookstores that have to be shown in the ListViewer?

Sharon Dagan wrote on Wed, 11 December 2013 20:26
My EMF domain looks something like this:

Bookstore {
  Book[] books
  ...
}


How do I bind an instance of Bookstore, which is my top level object to the input of a JFace viewer?
i.e.,

<ListViewer input="{Binding Path=this}">


Rather than

// this works
<ListViewer input="{Binding Path=books}">


Thanks,
-S.


Previous Topic:Where do you call SomeJFaceViewer.setInput
Next Topic:IStructuredContentProvider.getElements being called twice
Goto Forum:
  


Current Time: Tue Jul 22 11:38:29 EDT 2014

Powered by FUDForum. Page generated in 0.03447 seconds