Table Item to Details

I’m hoping for some help, I’m a beginner so if I missed the search for this in an example feel free to direct me to that location (I’ve done a bit of searching, but might be using the incorrect terminology).

Overall issue:
Have a table which contains a list of objects, however the display only shows a subset of the values per object.
Upon double clicking of one row, I’d like to have a modal window display with the complete details of that object.

The issue that I’m having is once I have captured the double click event, is getting the original specific object out of the list which the table was built and then pass that object to the layout for the modal window.

It seems like I have to get a property/set of properties out of that Item that is returned and then scan the original list (which is not directly accessible by the item click based on the design that I have – so I’m not sure how to do that) to get the specific object. I can then pass that object to my custom layout in order to biuld the form/details view of that item?

I feel like I am missing something. Since each row represents an object (bean item – or more specifically an object), is it possible to obtain the original object representation of that bean item?

I hope I’m making sense.

Thanks for the help!

Are you using BeanItemContainer to populate the Table? In that case you can do something like

BeanItemContainer<MyObject> container = (BeanItemContainer<MyObject>)table.getContainerDataSource();
MyObject bean = container.getItem(table.getValue()).getBean()

So… that sort of works… In Eclipse, I get everything fine. But when I run it in a browser (IE 7 or Firefox 3.6), it throws a null pointer exception on the table.getValue() call.

Thanks for the assistance, it figures it was something as obvious as that (where is that facepalm smiley?)…

getValue() was just an example (the currently selected item id). If you are using an ItemClickListener you should check the ClickEvent for details on what itemId was clicked and use that instead.

Well, that cleared that up.

Thanks for your help Artur.