You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by jensebhasen <Je...@motorolasolutions.com> on 2011/11/16 14:32:03 UTC

Adding domain object data to tableview

Hi,

I've been looking at the data binding example, tried searching this
mailinglist, and looked in the java API, but it all left me a bit confused
with regards to how I can easily map data from my domain objects (plain
beans) to columns in a tableview.

I managed to create BeanAdapter for one of my domain objects:

		Device device = new Device();
		device.setDeviceName("device1");
		BeanAdapter beanAdapter = new BeanAdapter(device);

And that works as expected. The TableView class do have a
setTableDataBindMapping() method, but I simply cannot get my head around how
I easily map the data and the table together.

The basic scenario is that I get a list of devices, and each device should
populate a row in the TableView. The number of columns might be <= the
number of properties available in the domain object; in other words the end
user might choose to only view a subset of the properties available, but I
think that is a minor issue, which I can figure out myself later.

-----
Regards
Jens
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Adding-domain-object-data-to-tableview-tp3512621p3512621.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Adding domain object data to tableview

Posted by Greg Brown <gk...@verizon.net>.
You get an exception when using a key that does not exist in your bean? It does seem like that should be OK. I'd expect the column to simply be empty in this case - not sure about the idea of providing a default property for what might be considered developer error.

On Nov 16, 2011, at 9:17 AM, jensebhasen <Je...@motorolasolutions.com> wrote:

> Hi again
> 
> Was just thinking ... in terms of robustness in this data-driven approach,
> which automatically grabs data of my domain object using the appropriate
> getter method - what if for some reason I'm requesting a property which is
> not present in the domain object?
> 
> Just tired that, and it thrown a IllegalArgumentException in my face
> straight away and left me with an empty window. Maybe just out of interest
> would I be able to somehow provide a default value in case I cannot get a
> value from my domain object?
> 
> -----
> Regards
> Jens
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Adding-domain-object-data-to-tableview-tp3512621p3512731.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Adding domain object data to tableview

Posted by jensebhasen <Je...@motorolasolutions.com>.
Hi again

Was just thinking ... in terms of robustness in this data-driven approach,
which automatically grabs data of my domain object using the appropriate
getter method - what if for some reason I'm requesting a property which is
not present in the domain object?

Just tired that, and it thrown a IllegalArgumentException in my face
straight away and left me with an empty window. Maybe just out of interest
would I be able to somehow provide a default value in case I cannot get a
value from my domain object?

-----
Regards
Jens
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Adding-domain-object-data-to-tableview-tp3512621p3512731.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Adding domain object data to tableview

Posted by jensebhasen <Je...@motorolasolutions.com>.
Hi

Great, thanx. Now it works :-)

-----
Regards
Jens
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Adding-domain-object-data-to-tableview-tp3512621p3512696.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Adding domain object data to tableview

Posted by Greg Brown <gk...@verizon.net>.
You can just use instances of your bean as your table rows. Just name the columns according to your bean property names.

FYI, this is not considered "data binding". TableView is considered a "data-driven" component.

On Nov 16, 2011, at 8:32 AM, jensebhasen <Je...@motorolasolutions.com> wrote:

> Hi,
> 
> I've been looking at the data binding example, tried searching this
> mailinglist, and looked in the java API, but it all left me a bit confused
> with regards to how I can easily map data from my domain objects (plain
> beans) to columns in a tableview.
> 
> I managed to create BeanAdapter for one of my domain objects:
> 
>        Device device = new Device();
>        device.setDeviceName("device1");
>        BeanAdapter beanAdapter = new BeanAdapter(device);
> 
> And that works as expected. The TableView class do have a
> setTableDataBindMapping() method, but I simply cannot get my head around how
> I easily map the data and the table together.
> 
> The basic scenario is that I get a list of devices, and each device should
> populate a row in the TableView. The number of columns might be <= the
> number of properties available in the domain object; in other words the end
> user might choose to only view a subset of the properties available, but I
> think that is a minor issue, which I can figure out myself later.
> 
> -----
> Regards
> Jens
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Adding-domain-object-data-to-tableview-tp3512621p3512621.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.