Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

How can I Update item on Vaadin's Grid without putting explicitly all field

Deleted User
7 years ago May 21, 2015 10:02am
Marko Grönroos
7 years ago May 21, 2015 11:21am

Is there any particular reason to use IndexedContainer instead of BeanItemContainer? The BIC writes changes directly to the beans...

ValueChangeListener is bound to a Property, and does not know anything about the item in which the property is; hence it doesn't get the item ID. If you use one VCL per property, you can store the item ID in your VCL implementation.

If you want to handle saving the Grid editor in some special way, you can extend Grid and override saveEditor() to add custom behaviour.

Deleted User
7 years ago May 21, 2015 11:38am
Marko Grönroos
7 years ago May 21, 2015 3:01pm

I don't quite know what your case exactly is, but IndexedContainer is not normally used when you have beans. But if you want to do it that way, overriding saveEditor() would maybe be the best way. A CommitHandler is probably not what you need; it's a FieldGroup feature and a FG is bound to an item. An item doesn't have any identity (such as item ID) in itself, but only in the context of a container containing many items. I suppose you could get the item ID of the currently edited item in a commit handler, if you pass a reference to the Grid to it.

Regarding BIC:

  1. If a column is hidden or read-only, it's not possible to change the values.
  2. What do you mean by column name here? You can set column caption with getColumn("mycolumn").setHeaderCaption("My Nice Column")
  3. Yeah, that gets difficult. You could merge columns with a GeneratedPropertyContainer, but the generated properties are indeed read-only. You could do it by adding a merged property in your bean or by wrapping the beans in a wrapper with such a merged property, which handles merging the field values, as well as a setter that "unmerges" the values.
Deleted User
7 years ago May 21, 2015 3:10pm
Marko Grönroos
7 years ago May 21, 2015 3:17pm
Deleted User
7 years ago May 21, 2015 3:30pm