Making a column read-only when using BeanItemContainer

Is there a way to make a column (i.e., a property) read-only? For example, I have a POJO where I have get/set methods for a property, but I don’t want the table to be able to edit that property. I can’t remove the set method because it’s used elsewhere by non-Vaadin code.

Obviously, I can use getContainerProperty(), but that would require me to iterate through all of the items and then set the Read Only property on the specific property for the item. Is there an easier way?

;ted

It’s not pretty, but integration rarely is, since it sounds like you are not already using a vaadin-specific bean adapter class, you may consider just adding a vaadin-only getter and then using that instead of your standard.

i.e. int getNumber() with void setNumber(int v) in your standard bean, you’d also create a vaadin-specific hack like: final int getNumberForVaadin() { return getNumber(); }

One option would be to handle this in the field factory for your table, first asking the default (or custom) field factory to create the field and then setting the fields as read-only for that property. Or you could probably also override Table.getPropertyValue(…) to simply return formatPropertyValue(…) for that property id and otherwise call super.getPropertyValue().

Other options (on the level of the container) are more complicated as the read-only status is handled by individual Property instances, not by the Container.