Grid editor has read-only fields with BeanItemContainer

Hi, first of all the Grid comp. is truly awesome, thanks for the excellent work!

I have an issue with Grid editor using BeanItemContainer. When I doubleclik a row or programmatically open the row editor I can’t edit the fields in it. All the fields are read-only, I don’t know why.

I can’t find any solution for the problem on any site or StackOverflow. I have tried to change the container to simply BeanContainer, but either way it’s not working.

I would appreciate any help to solve this problem I am struggling for hours :confused:

The relevant source code:

BeanItemContainer container = new BeanItemContainer<ScheduleTimeWindow>(ScheduleTimeWindow.class);
Grid grid = new Grid(container);
grid.removeColumn("element");
grid.removeColumn("id");
grid.removeColumn("new");
grid.removeColumn("required");
grid.removeColumn("version");

grid.setColumnOrder(JOB, NECESSARY, RESERVED, ARRIVAL, LEAVE);
grid.setEditorFieldGroup(new BeanFieldGroup<>(ScheduleTimeWindow.class));

IndexedContainer jobContainer = new IndexedContainer();
jobContainer.addContainerProperty(CAPTION, String.class, null);
jobCombo = new ComboBox(null, jobContainer);
jobCombo.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
jobCombo.setItemCaptionPropertyId(CAPTION);
jobCombo.setNullSelectionAllowed(false);
grid.getColumn(JOB).setEditorField(jobCombo).setConverter(new JobToStringConverter());

Does your Bean class have setters for all properties?

Thanks for the fast reply.
The Bean have all the setters and getters for the fields what I am gonna use. Altought there is one field named “element” that have private setter, but I am not using that field, I am removing it’s column. Is this would be the problem?

I might click on the wrong Reply button, not the one on your post’s, sorry. So…

“The Bean have all the setters and getters for the fields what I am gonna use. Altought there is one field named “element” that have private setter, but I am not using that field, I am removing it’s column. Is this would be the problem?”

Might want to try commenting our your private setter and see if it works. I had a Bean with private functions and setters and it kept the grid from working, but if I just kept everything as a generic get / set, it worked fine.

You can still keep the element, just remove the column if you don’t want it to show up and have the public get / set functions.

I definitely give it a try and comment back.
Alisa, thank you!

grid expects the Java bean to have void setXXX() method signature. At least that was a problem I faced when I was having builder pattern for setters.All setters() with “return this.”. Non-void setters mean the column becomes non-editable by default.

This is THE solution, thank you :wink:
The return setXXX signature was the source of the problem. We refactored the Bean and it is editable in Grid editor.

I was wondering why Grid editor works like this way. Why would it cares about setter signatures (void or return type)?
Our application have a lot of Bean (over 50) and we use their setter/getter in chain in a lot of spaces :frowning: