Table.setTableFieldFactory() called only when edit = true?

Ok. I’m a newby with Vaadin, so please forgive me, but I’m trying to learn.

I have a Table with a dataSource being fed by LazyQueryContainer from a database.

Some of the columns are foreign key id values as Long.

I want to show a suitable foreign value when not in edit mode, and then allow users to select the foreign record when in edit mode via a combo box kind of deal.

I appear to have to define the column datatype as Long for these columns, otherwise I get the following error (when I declare it as a ComboBox for example):

SEVERE: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
at com.vaadin.ui.Table.paintRow(Table.java:2572)
at com.vaadin.ui.Table.paintContent(Table.java:2408)
at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:754)
at com.vaadin.ui.AbstractOrderedLayout.paintContent(AbstractOrderedLayout.java:161)
at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:754)
at com.vaadin.ui.AbstractOrderedLayout.paintContent(AbstractOrderedLayout.java:161)
at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:754)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.paintAfterVariableChanges(AbstractCommunicationManager.java:807)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:621)
at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:266)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:476)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

However, if I set the data type as Long, the value gets rendered simply as a text field, and does not look up the value I want.

I thought I might be able to get away with providing a TableFieldFactory for the table, but, it appears that this class only gets called when the table is in edit mode, which I think is a bit unhelpful in this case.

So, Vaadin Guru’s… what is the solution?

I have an indexed container holding the foreign table’s values & id’s, with which to look up the value that should be displayed, but how do I get the Table to ask me how to render these Long columns when not in edit mode?

Am I supposed to dynamically provide or rip out columnGenerators for these fields when switching between edit and non-edit mode?

Perhaps a solution to the problem would be to alter Table.getPropertyValue so that depending on a set parameter (eg: Table.setAlwaysCallFactory(true); ) it could be made to always call the factory rather than just when in edit mode.

this would make it possible to just have the one piece of code where in the data columns could have custom mappings to properties could be controlled from our own project code?

currently, it *only will call the factory if the table is in edit mode, which I see as being a problem.