Partial items in table, full item in detailed form


My application displays a list of articles in a table and a detailed article form for the article that is clicked on in the table.
The articles have several images that I don’t want to load when populating the list. The detailed form should display the whole article, including images. What’s the best approach for this?

Changing the selected article is now handled by a handler, much like the person tutorial one:

	public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
		Property property = valueChangeEvent.getProperty();
		if (property == articleList) {
			Item item = articleList.getItem(articleList.getValue());
			if (item != articleForm.getItemDataSource()) {

So, somehow when I pass the item to the articleForm, I want it to be the full article where it is only a partial article in the list.


Does Table.setVisibleColumns() do what you want?
Note that you need to call this after setting the data source.

Hi Henri,

Thanks for the quick reply.
What I want to avoid is having a hibernate query that populate articles with several images for each article in the table, where the images are not necessary. It doesn’t scale well. Table.setVisibleColumns() doesn’t help here, I assume. What I would want is to fetch a “full” version of the article—including the images—from the database only when it’s needed for the detail view and inject that into the Item before displaying the detail form (also making the changes to the full version persistable).


You will likely have to split your entity in two parts. If you enable “showsql=true” in your hibernate configuration, you will see that Hibernate fetches all the fields. So you will need to store things as a composite, with one-to-one relationship between the summary part and the image part, and make sure you use lazy loading (as opposed to eager).

Then when you navigate from the summary to your form you can construct an item with all the parts. You could actually use two items (one for each part) and combine them as a larger item if that is convenient for you, or use the two items.

Thanks Jean-François,

You’re suggested approach was very useful to me.


If you model does not permit split the data, you can use lazy load.

If the property is a normal field, you can use

private byte[] myLargeBinaryData;

Remembering that many JPA implementations do not deal well with lazy loading across transactions/sessions, once the entity instance has been detached, so you might need to reattach (using merge() which has side effects) or reload (based on the ID) the parent entity before accessing the lazily loaded field.